diff --git a/README.md b/README.md new file mode 100644 index 0000000..7923f1b --- /dev/null +++ b/README.md @@ -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). diff --git a/dark.json b/dark.json index e760449..045fc5c 100644 --- a/dark.json +++ b/dark.json @@ -5,6 +5,12 @@ }, "heading": { "bold": true, - "inverse": true + "color": "3" + }, + "code": { + "color": "200" + }, + "code_block": { + "color": "200" } } diff --git a/main.go b/main.go index fc0eab9..afe48bc 100644 --- a/main.go +++ b/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)) }