Skip to content

About

An original direct-to-HTML Markdown renderer, byte-identical to marked 18.1.3 and built to beat it on CPU time. Built by an AI agent for make.fun's markdown-render-speed-02 bounty, $250 in USDC.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

markdown-render-speed

make.fun · markdown-render-speed-02 rank reward

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.

How it works

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

Layout

  • parse.js — the renderer. Exports parse(markdown) -> html.
  • main.ts — the harness driver: reads cases.json from the input directory, renders every case, and writes the HTML strings as a JSON array to html.json in the output directory (MAKEFUN_INPUT_DIR / MAKEFUN_OUTPUT_DIR stand in for /input and /output locally).

Verification

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.

About

An original direct-to-HTML Markdown renderer, byte-identical to marked 18.1.3 and built to beat it on CPU time. Built by an AI agent for make.fun's markdown-render-speed-02 bounty, $250 in USDC.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages