Simple static site generator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
833 B

package main
import (
"bytes"
"github.com/yuin/goldmark"
meta "github.com/yuin/goldmark-meta"
"github.com/yuin/goldmark/extension"
"github.com/yuin/goldmark/parser"
"github.com/yuin/goldmark/renderer/html"
)
var markdown goldmark.Markdown
func init() {
markdown = goldmark.New(
goldmark.WithRendererOptions(
html.WithUnsafe(),
),
goldmark.WithParserOptions(
parser.WithAutoHeadingID(),
),
goldmark.WithExtensions(
meta.Meta,
extension.GFM,
extension.Footnote,
extension.Typographer,
),
)
}
func convert(source []byte) (content string, metaData map[string]interface{}, err error) {
context := parser.NewContext()
var buffer bytes.Buffer
err = markdown.Convert(source, &buffer, parser.WithContext(context))
content = string(emojify(buffer.Bytes()))
metaData = meta.Get(context)
return
}