hugo-to-gemini/render.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

16 lines
505 B
Go

package gemini
import (
"git.tdem.in/tdemin/gmnhg/internal/gemini"
"github.com/gomarkdown/markdown"
"github.com/gomarkdown/markdown/parser"
)
// RenderMarkdown converts Markdown text to text/gemini using gomarkdown.
//
// gomarkdown doesn't return any errors, nor does this function.
func RenderMarkdown(md []byte) (geminiText []byte) {
ast := markdown.Parse(md, parser.NewWithExtensions(parser.CommonExtensions))
geminiContent := markdown.Render(ast, gemini.NewRenderer())
return geminiContent
}