main
1package main
2
3import (
4 chromahtml "github.com/alecthomas/chroma/v2/formatters/html"
5 "github.com/yuin/goldmark"
6 highlighting "github.com/yuin/goldmark-highlighting/v2"
7 "github.com/yuin/goldmark/extension"
8 "github.com/yuin/goldmark/parser"
9 gmhtml "github.com/yuin/goldmark/renderer/html"
10)
11
12func createMarkdown(style string) goldmark.Markdown {
13 return goldmark.New(
14 goldmark.WithExtensions(
15 extension.GFM,
16 extension.Typographer,
17 highlighting.NewHighlighting(
18 // This assumes that the classes stay the same,
19 // regardless of style, which should be true
20 highlighting.WithStyle(style),
21 highlighting.WithFormatOptions(
22 chromahtml.WithClasses(true),
23 ),
24 ),
25 ),
26 goldmark.WithParserOptions(
27 parser.WithAutoHeadingID(),
28 ),
29 goldmark.WithRendererOptions(
30 gmhtml.WithUnsafe(),
31 ),
32 )
33}