feat: render Markdown, mathematics and Mermaid diagrams server-side
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user