feat: render Markdown, mathematics and Mermaid diagrams server-side

This commit is contained in:
2026-09-27 19:15:50 +02:00
commit 35bc42623b
72 changed files with 8914 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
// SPDX-License-Identifier: MIT
// Package markdown renders Markdown to HTML with an engine of its own,
// built on the standard library alone. Parse builds the tree of blocks
// and RenderHTML serialises it; the grammar of the block structure follows
// CommonMark. Inline content is escaped plain text.
package markdown
// RenderHTML parses source and renders it to HTML. The same input always
// produces byte-identical output.
func RenderHTML(source []byte) []byte {
return RenderHTMLNode(Parse(source))
}
// RenderHTMLNode renders a parsed document tree to HTML.
func RenderHTMLNode(doc *Node) []byte {
r := &renderer{refs: doc.refs, footnotes: newFootnoteTracker(doc.footnotes)}
r.blocks(doc.children)
r.footnoteSection()
return r.out
}