format

package
v0.0.0-...-6c7f99c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 7 Imported by: 0

README

Gum Format

Gum format allows you to format different text into human readable output.

Four different parse-able formats exist:

  1. Markdown
  2. Code
  3. Template
  4. Emoji

Markdown

Render any input as markdown text. This uses Glamour behind the scenes.

You can pass input as lines directly as arguments to the command invocation or pass markdown over stdin.

gum format --type markdown < README.md
# Or, directly as arguments (useful for quick lists)
gum format --type markdown -- "# Gum Formats" "- Markdown" "- Code" "- Template" "- Emoji"

Code

Render any code snippet with syntax highlighting. Glamour, which uses Chroma under the hood, handles styling.

Similarly to the markdown format, code can take input over stdin.

cat options.go | gum format --type code

Template

Render styled input from a string template. Templating is handled by Termenv.

gum format --type template '{{ Bold "Tasty" }} {{ Italic "Bubble" }} {{ Color "99" "0" " Gum " }}'
# Or, via stdin
echo '{{ Bold "Tasty" }} {{ Italic "Bubble" }} {{ Color "99" "0" " Gum " }}' | gum format --type template 

Emoji

Parse and render emojis from their matching :name:s. Powered by Glamour and Goldmark Emoji

gum format --type emoji 'I :heart: Bubble Gum :candy:'
# You know the drill, also via stdin
echo 'I :heart: Bubble Gum :candy:' | gum format --type emoji 

Documentation

Overview

Package format allows you to render formatted text from the command line.

It supports the following types:

1. Markdown 2. Code 3. Emoji 4. Template

For more information, see the format/README.md file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Template []string `arg:"" optional:"" help:"Template string to format (can also be provided via stdin)"`
	Theme    string   `help:"Glamour theme to use for markdown formatting" default:"pink" env:"GUM_FORMAT_THEME"`
	Language string   `help:"Programming language to parse code" short:"l" default:"" env:"GUM_FORMAT_LANGUAGE"`

	Type string `` /* 138-byte string literal not displayed */
}

Options is customization options for the format command.

func (Options) Run

func (o Options) Run() error

Run runs the format command.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL