docs: move information to format/README.md

This commit is contained in:
Maas Lalani 2022-07-14 16:32:40 -04:00
parent 4dd438bad1
commit e17e45aa9b
No known key found for this signature in database
GPG key ID: 5A6ED5CBF1A0A000
4 changed files with 68 additions and 123 deletions

59
format/README.md Normal file
View file

@ -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
```

View file

@ -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

44
gum.go
View file

@ -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.

41
pink.md
View file

@ -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