Update main.go: Log to stdout & support both html and html-chroma

Could be moved into a flag but I'll significantly refactor the main.go later on
anyways - for now this works TM
This commit is contained in:
Niklas Fasching 2018-12-11 14:42:05 +01:00
parent 6637e63892
commit 6adad92e8b
2 changed files with 5 additions and 2 deletions

View file

@ -20,4 +20,4 @@ setup:
case=example
.PHONY: render
render:
bash -c "go run main.go org/testdata/$(case).org html |& html2text"
go run main.go org/testdata/$(case).org html | html2text

View file

@ -16,9 +16,10 @@ import (
func main() {
log.SetFlags(0)
log.SetOutput(os.Stdout)
if len(os.Args) < 3 {
log.Println("USAGE: org FILE OUTPUT_FORMAT")
log.Fatal("supported output formats: org, html")
log.Fatal("supported output formats: org, html, html-chroma")
}
bs, err := ioutil.ReadFile(os.Args[1])
if err != nil {
@ -29,6 +30,8 @@ func main() {
case "org":
out = org.NewDocument().Parse(r).Write(org.NewOrgWriter()).String()
case "html":
out = org.NewDocument().Parse(r).Write(org.NewHTMLWriter()).String()
case "html-chroma":
writer := org.NewHTMLWriter()
writer.HighlightCodeBlock = highlightCodeBlock
out = org.NewDocument().Parse(r).Write(writer).String()