Skip to main content

Module markdown

Module markdown 

Source
Expand description

Minimal, safety-first Markdown → HTML: used for comment bodies and for the rendered view of markdown files on the generated page.

Safety by construction: every input character is HTML-escaped first; the only tags in the output are the ones this module emits, and link targets are restricted to http:// / https:// / mailto: — hostile input cannot smuggle markup or javascript: URLs.

Deliberately a SUBSET (documented in docs/PAGE.md): ATX headings, fenced code blocks, flat (non-nested) lists, blockquotes, thematic breaks, paragraphs; inline `code`, **bold**, *italic*, and [links](https://…). Underscores are NOT emphasis, so snake_case identifiers survive verbatim. A single newline inside a paragraph is a hard break, matching how people write review comments.

Functions§

to_html
Render markdown text to HTML. Pure and deterministic; never fails — anything unrecognized falls back to escaped literal text.
to_html_blocks
Like to_html, but one entry per top-level block: (line, html), where line is the 0-based index (within text) of the block’s first line. Concatenating the html parts yields exactly to_html(text). This is what lets the page anchor a comment on a rendered markdown block back to the source line the block starts at.