gum/format
2024-01-13 23:12:03 -05:00
..
command.go feat: allow passing language to parse code 2023-03-24 13:40:37 -04:00
formats.go fix(format): force ansi256 for template formatting 2024-01-13 23:12:03 -05:00
options.go feat(format): add GUM_FORMAT_THEME / GUM_FORMAT_LANGUAGE environment variable configuration 2023-05-11 23:45:29 -04:00
README.md docs: move information to format/README.md 2022-07-14 16:33:16 -04:00

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