markdown

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(source []byte, plantumlServer string) ([]byte, error)

Convert converts Markdown source to HTML. plantumlServer is the PlantUML server URL for code block conversion.

func ConvertText added in v0.2.0

func ConvertText(source []byte) []byte

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

func PreprocessCodeBlocks(source []byte, plantumlServer string) []byte

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

func PreprocessMathBlocks(source []byte) []byte

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).

func RewriteLinks(htmlContent []byte, scheme string, server string) []byte

RewriteLinks rewrites links in HTML content for proxy navigation. scheme is "local", "http", or "https". server is the remote server host (empty for local).

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL