mirror of
https://github.com/charmbracelet/glow
synced 2024-09-21 00:42:21 +00:00
Much better parsing, README example
This commit is contained in:
parent
dda88169f4
commit
09bb6b3dd1
15
README.md
Normal file
15
README.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
# Charm Gold
|
||||
|
||||
Render markdown on the CLI, with _pizzazz_!
|
||||
|
||||
## Usage
|
||||
|
||||
Supply a JSON stylesheet with the `-s` flag. Use a markdown file as the argument.
|
||||
|
||||
```
|
||||
./gold -s dark.json README.md
|
||||
```
|
||||
|
||||
## Colors
|
||||
|
||||
Currently `gold` uses the [Aurora ANSI colors](https://godoc.org/github.com/logrusorgru/aurora#Index).
|
|
@ -5,6 +5,12 @@
|
|||
},
|
||||
"heading": {
|
||||
"bold": true,
|
||||
"inverse": true
|
||||
"color": "3"
|
||||
},
|
||||
"code": {
|
||||
"color": "200"
|
||||
},
|
||||
"code_block": {
|
||||
"color": "200"
|
||||
}
|
||||
}
|
||||
|
|
17
main.go
17
main.go
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/magicnumbers/gold"
|
||||
|
@ -26,11 +27,23 @@ This is a test yo.
|
|||
func main() {
|
||||
s := flag.String("s", "", "style json path")
|
||||
flag.Parse()
|
||||
args := flag.Args()
|
||||
if len(args) != 1 {
|
||||
fmt.Println("Missing Markdown file. Usage: ./gold -s STYLE.json FILE.md")
|
||||
os.Exit(1)
|
||||
}
|
||||
f, err := os.Open(args[0])
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer f.Close()
|
||||
b, _ := ioutil.ReadAll(f)
|
||||
r, err := gold.NewTermRenderer(*s)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
out := bf.Run([]byte(tmd), bf.WithRenderer(r))
|
||||
fmt.Println(string(out))
|
||||
out := bf.Run(b, bf.WithRenderer(r))
|
||||
fmt.Printf("%s", string(out))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue