diff --git a/format/README.md b/format/README.md new file mode 100644 index 0000000..288f234 --- /dev/null +++ b/format/README.md @@ -0,0 +1,59 @@ +# Gum Format + +Gum format allows you to format different text into human readable output. + +Four different parse-able formats exist: + +1. [Markdown](#markdown) +2. [Code](#code) +3. [Template](#template) +3. [Emoji](#emoji) + +## Markdown + +Render any input as markdown text. This uses +[Glamour](https://github.com/charmbracelet/glamour) behind the scenes. + +You can pass input as lines directly as arguments to the command invocation or +pass markdown over `stdin`. + +```bash +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](https://github.com/charmbracelet/glamour), which uses +[Chroma](https://github.com/alecthomas/chroma) under the hood, handles styling. + +Similarly to the `markdown` format, `code` can take input over `stdin`. + +```bash +cat options.go | gum format --type code +``` + +## Template + +Render styled input from a string template. Templating is handled by +[Termenv](https://github.com/muesli/termenv). + +```bash +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](https://github.com/charmbracelet/glamour) and [Goldmark +Emoji](https://github.com/yuin/goldmark-emoji) + +```bash +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 +``` diff --git a/format/command.go b/format/command.go index a8c7d19..3797c23 100644 --- a/format/command.go +++ b/format/command.go @@ -1,48 +1,13 @@ // Package format allows you to render formatted text from the command line. -// There are a few different types of formats that can be used: // -// 1. Markdown -// ------------- -// Render any input as markdown text. This uses glamour behind the scenes. -// Input passed as arguments are placed on new lines. -// Input passed as stdin are rendered as is. -// https://github.com/charmbracelet/glamour +// It supports the following types: // -// $ gum format '**Tasty** *Bubble* `Gum`' -// $ gum format "1. List" "2. Of" "3. Items" -// $ echo "# Bubble Gum \n - List \n - of \n - Items" | gum format -// $ gum format -- "- Bulleted" "- List" +// 1. Markdown +// 2. Code +// 3. Emoji +// 4. Template // -// Or, pass input via stdin: -// -// $ echo '**Tasty** *Bubble* `Gum`' | gum format -// -// 2. Template -// ------------- -// Render styled input from a template. Templates are handled by termenv. -// https://github.com/muesli/termenv -// -// $ gum format '{{ Bold "Tasty" }} {{ Italic "Bubble" }} {{ Color "99" "0" " Gum " }}' --type template -// -// 3. Code -// ------------- -// Perform syntax highlighting on some code snippets. Styling is handled by -// glamour, which in turn uses chroma. https://github.com/alecthomas/chroma -// -// $ cat code.go | gum format --type code -// -// 4. Emoji -// ------------- -// Parse emojis within text and render emojis. Emoji rendering is handled by -// glamour, which in turn uses goldmark-emoji. -// https://github.com/yuin/goldmark-emoji -// -// $ gum format 'I :heart: Bubble Gum :candy:' --type emoji -// $ echo "I :heart: Bubble Gum :candy:" | gum format --type emoji -// -// Output: -// -// I ❤️ Bubble Gum 🍬 +// For more information, see the format/README.md file. // package format diff --git a/gum.go b/gum.go index 1079550..ac671e6 100644 --- a/gum.go +++ b/gum.go @@ -40,47 +40,9 @@ type Gum struct { // Filter filter.Options `cmd:"" help:"Filter items from a list"` - // Package format allows you to render formatted text from the command line. - // There are a few different types of formats that can be used: - // - // 1. Markdown - // ───────────── - // Render any input as markdown text. This uses glamour behind the scenes. - // https://github.com/charmbracelet/glamour - // - // $ gum format '**Tasty** *Bubble* `Gum`' - // - // Or, pass input via stdin: - // - // $ echo '**Tasty** *Bubble* `Gum`' | gum format - // - // 2. Template - // ───────────── - // Render styled input from a template. Templates are handled by termenv. - // https://github.com/muesli/termenv - // - // $ gum format '{{ Bold "Tasty" }} {{ Italic "Bubble" }} {{ Color "99" "0" " Gum " }}' --type template - // - // 3. Code - // ───────────── - // Perform syntax highlighting on some code snippets. Styling is handled by - // glamour, which in turn uses chroma. https://github.com/alecthomas/chroma - // - // $ cat code.go | gum format --type code - // - // 4. Emoji - // ───────────── - // Parse emojis within text and render emojis. Emoji rendering is handled by - // glamour, which in turn uses goldmark-emoji. - // https://github.com/yuin/goldmark-emoji - // - // $ gum format 'I :heart: Bubble Gum :candy:' --type emoji - // $ echo "I :heart: Bubble Gum :candy:" | gum format --type emoji - // - // Output: - // - // I ❤️ Bubble Gum 🍬 - // + // Format allows you to render styled text from `markdown`, `code`, + // `template` strings, or embedded `emoji` strings. + // For more information see the format/README.md file. Format format.Options `cmd:"" help:"Format a string using a template"` // Input provides a shell script interface for the text input bubble. diff --git a/pink.md b/pink.md deleted file mode 100644 index a053666..0000000 --- a/pink.md +++ /dev/null @@ -1,41 +0,0 @@ - -# Pink Theme - -Code: `pink theme` - -``` -echo "Hello, Pink theme!" -``` - -## Header 2 - -- List Item 1 -- List Item 2 -- List Item 3 - -### Header 3 - -This is just a normal paragraph. - -#### Header 4 -- [ ] Checkbox 1 -- [x] Checkbox 2 - -~~Strikethrough~~ - ---- - -[Glamour](https://github.com/charmbracelet/glamour) - -![Glamour](https://github.com/charmbracelet/glamour.png) - -> Block Quote - -##### Header 5 - -**Bold** Text - -###### Header 6 - -- List Item 1 -- List Item 2