Documentation
¶
Index ¶
- func Convert(source []byte, plantumlServer string) ([]byte, error)
- func ConvertText(source []byte) []byte
- func PreprocessCodeBlocks(source []byte, plantumlServer string) []byte
- func PreprocessMathBlocks(source []byte) []byte
- func RewriteLinks(htmlContent []byte, scheme string, server string) []byte
- type SafeInlineMathRenderer
- type SafeMathBlockRenderer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Convert ¶
Convert converts Markdown source to HTML. plantumlServer is the PlantUML server URL for code block conversion.
func ConvertText ¶ added in v0.2.0
ConvertText converts plain text content to HTML with line anchors. Each line is wrapped in a <span id="Ln" class="source-line"> for individual line-level highlighting. The output is in a <pre><code> block.
func PreprocessCodeBlocks ¶
PreprocessCodeBlocks replaces svg, mermaid, and plantuml fenced code blocks in Markdown source with raw HTML before goldmark processing. Returns the processed source and is safe because goldmark is configured with html.WithUnsafe().
func PreprocessMathBlocks ¶ added in v0.2.0
PreprocessMathBlocks ensures that $$ delimiters are on their own lines so that goldmark-mathjax can parse them correctly. It handles three cases:
- Single-line: $$content$$ → $$\ncontent\n$$
- Opening with content: $$content...\n → $$\ncontent...\n
- Closing with content: ...content$$ → ...content\n$$
Fenced code blocks are skipped to avoid modifying code content. Only exactly two consecutive $ characters are treated as delimiters ($$$ or more are left for goldmark-mathjax to handle directly).
Types ¶
type SafeInlineMathRenderer ¶ added in v0.2.0
type SafeInlineMathRenderer struct{}
SafeInlineMathRenderer renders InlineMath nodes with HTML escaping. The upstream goldmark-mathjax renderer writes raw source bytes without escaping, so characters like <, >, & break browser rendering.
func (*SafeInlineMathRenderer) RegisterFuncs ¶ added in v0.2.0
func (r *SafeInlineMathRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer)
type SafeMathBlockRenderer ¶ added in v0.2.0
type SafeMathBlockRenderer struct{}
SafeMathBlockRenderer renders MathBlock nodes with HTML escaping.
func (*SafeMathBlockRenderer) RegisterFuncs ¶ added in v0.2.0
func (r *SafeMathBlockRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer)