all repos — vite @ c720289599cf73858c8150484d1b3fdafcaa5595

a fast (this time, actually) and minimal static site generator

markdown.go (view 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
package main

import (
	bfc "github.com/Depado/bfchroma"
	bf "github.com/russross/blackfriday/v2"
)

var bfFlags = bf.UseXHTML | bf.Smartypants | bf.SmartypantsFractions |
	bf.SmartypantsDashes | bf.NofollowLinks
var bfExts = bf.NoIntraEmphasis | bf.Tables | bf.FencedCode | bf.Autolink |
	bf.Strikethrough | bf.SpaceHeadings | bf.BackslashLineBreak |
	bf.HeadingIDs | bf.Footnotes | bf.NoEmptyLineBeforeBlock

func mdRender(input []byte) []byte {
	return bf.Run(
		input,
		bf.WithRenderer(
			bfc.NewRenderer(
				bfc.Style("bw"),
				bfc.Extend(
					bf.NewHTMLRenderer(bf.HTMLRendererParameters{
						Flags: bfFlags,
					}),
				),
			),
		),
		bf.WithExtensions(bfExts),
	)
}