Goldmark Katex
August 13, 2026 ยท View on GitHub
Goldmark Katex is a Goldmark extension providing math and equation support through KaTeX.
Usage
// Default, errors are highlighted in red in the output
goldmark.New(goldmark.WithExtensions(&katex.Extender{})).Convert(src, dst)
// With ThrowOnError set to true
goldmark.New(goldmark.WithExtensions(&katex.Extender{
ThrowOnError: true,
})).Convert(src, dst)
Wrap inline math with a pair of single $:
$A$
Wrap block math with a pair of double $:
$$
A = \pi \times r^2
$$
A $$ that begins a line opens a block, which runs to the next $$ or to the
end of the document, much as a fenced code block does. The equation is parsed
before Markdown, so it is kept verbatim however long it is, and delimiters may
hug it:
$$\begin{aligned}
a &= b \\
c &= d
\end{aligned}$$
Double $ in the middle of a line is display math too, rendered in place within
the surrounding paragraph:
Einstein wrote $$E = mc^2$$ in 1905.
Example
|
|
