upstream
 1package main
 2
 3import (
 4	"html/template"
 5
 6	"github.com/yuin/goldmark"
 7	highlighting "github.com/yuin/goldmark-highlighting/v2"
 8	"github.com/yuin/goldmark/extension"
 9	"github.com/yuin/goldmark/parser"
10	gmhtml "github.com/yuin/goldmark/renderer/html"
11
12	"github.com/antonmedv/gitmal/pkg/templates"
13)
14
15func createMarkdown(style string) goldmark.Markdown {
16	return goldmark.New(
17		goldmark.WithExtensions(
18			extension.GFM,
19			extension.Typographer,
20			highlighting.NewHighlighting(
21				highlighting.WithStyle(style),
22			),
23		),
24		goldmark.WithParserOptions(
25			parser.WithAutoHeadingID(),
26		),
27		goldmark.WithRendererOptions(
28			gmhtml.WithUnsafe(),
29		),
30	)
31}
32
33func cssMarkdown(dark bool) template.CSS {
34	if dark {
35		return template.CSS(templates.CSSMarkdownDark)
36	}
37	return template.CSS(templates.CSSMarkdownLight)
38}