Znak
A parser for a Markdown-like markup language that supports a smaller subset of Markdown syntax, and is stricter and more opinionated. It has features like syntax highlighting, $\LaTeX$, and heading IDs built-in.
You can read the syntax here. You can also read the documentation for Highlight (the syntax highlighter in Znak) here.
Usage
Add it as a dependency to your project:
go get -u tangled.org/zerolimits.dev/znak
Then you can use it in your code:
package main
import (
"tangled.org/zerolimits.dev/znak"
"tangled.org/zerolimits.dev/znak/highlight"
)
func main() {
themeFile, err := os.ReadFile("path/to/theme.css")
codeTheme, err := highlight.NewTheme(themeFile)
inputFile, err := os.ReadFile("path/to/file.md")
input := string(inputFile)
renderedHtml, err := znak.Render(input, codeTheme)
headings := znak.Headings(input)
frontmatter, err := znak.Frontmatter(input)
}
Acknowledgements
$\LaTeX$ is rendered to MathML using Wyatt915/TreeBlood.
The example code theme in theme.css is taken from PyaeSoneAungRgn/github-zed-theme.