Home

blog @615129be36f02b57ea0065ba9af6196f34014938 - refs - log -
-
https://git.jolheiser.com/blog.git
My nonexistent blog
blog / goldmark.go
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package blog

import (
	chromahtml "github.com/alecthomas/chroma/v2/formatters/html"
	"github.com/yuin/goldmark"
	emoji "github.com/yuin/goldmark-emoji"
	highlighting "github.com/yuin/goldmark-highlighting/v2"
	meta "github.com/yuin/goldmark-meta"
	"github.com/yuin/goldmark/extension"
	"github.com/yuin/goldmark/parser"
	"github.com/yuin/goldmark/renderer/html"
)

// Markdown is the default markdown converter
// Set over this variable to alter how the other functions convert
var Markdown = goldmark.New(
	goldmark.WithParserOptions(
		parser.WithAutoHeadingID(),
	),
	goldmark.WithRendererOptions(
		html.WithUnsafe(),
	),
	goldmark.WithExtensions(
		extension.GFM,
		meta.Meta,
		emoji.Emoji,
		highlighting.NewHighlighting(
			highlighting.WithFormatOptions(
				ChromaOpts...,
			),
		),
	),
)

var ChromaOpts = []chromahtml.Option{
	chromahtml.WithClasses(true),
	chromahtml.WithAllClasses(true),
	chromahtml.WithLineNumbers(true),
}