An original, dependency-free Markdown renderer whose output is byte-identical to marked 18.1.3 (default options: GFM on, breaks off, pedantic off), built to beat marked on CPU time. Written from scratch for make.fun's markdown-render-speed-02 bounty — no marked source, no vendored code, no dependencies.
- Direct to HTML. The block scanner walks the source once and emits final HTML strings as it goes; there is no intermediate token tree for the document.
- Inline rendering is an index-based scanner that writes HTML directly: emphasis/strong via delimiter runs fitted to marked's exact behaviour (including its departures from the CommonMark algorithm), code spans, links and images (inline, reference, shortcut), autolinks and GFM extended autolinks, strikethrough, entities, backslash escapes, inline HTML, and hard breaks.
- Block level covers ATX and setext headings, thematic breaks, fenced and indented code, blockquotes with lazy continuation, lists (nested, loose/tight, task items), GFM tables with alignments, link reference definitions, HTML blocks, and paragraphs.
- Speed comes from fast paths for common shapes, charCode-based scanning instead of regex-heavy splitting, cheap pre-filters on hot checks (table delimiter rows, mask computation), and minimal allocation in the inner loops.
parse.js— the renderer. Exportsparse(markdown) -> html.main.ts— the harness driver: readscases.jsonfrom the input directory, renders every case, and writes the HTML strings as a JSON array tohtml.jsonin the output directory (MAKEFUN_INPUT_DIR/MAKEFUN_OUTPUT_DIRstand in for/inputand/outputlocally).
Against the bounty practice set (680 CommonMark 0.31.2 + GFM spec examples and 40 generated README-like documents), the renderer matches the reference output on 720/720 cases. On the same machine it renders the full practice set in roughly 0.37–0.45 s CPU versus roughly 0.67–0.77 s CPU for marked itself — about 1.8× faster.