hugo-to-gemini/cmd/md2gmn/main.go
Timur Demin 4d80d36f00
Provide a public API
This also introduces a simple program, md2gmn, that is meant for testing
the renderer on Markdown files. Nonetheless, it can be used as
a standalone tool as well.
2020-11-11 23:20:52 +05:00

35 lines
509 B
Go

// md2gmn converts Markdown text files to text/gemini.
package main
import (
"flag"
"io/ioutil"
"os"
gemini "git.tdem.in/tdemin/gmnhg"
)
func main() {
var (
input string
file *os.File
)
flag.StringVar(&input, "f", "", "input file")
flag.Parse()
if input != "" {
var err error
file, err = os.Open(input)
if err != nil {
panic(err)
}
} else {
file = os.Stdin
}
text, err := ioutil.ReadAll(file)
if err != nil {
panic(err)
}
os.Stdout.Write(gemini.RenderMarkdown(text))
}