Skip to content

Markdown Conformance

Lanexio™ Parser’s Markdown parser passes all 652 CommonMark 0.31.2 examples and all 648 GFM examples.

CommonMark 0.31.2 is continuously validated in CI through two surfaces:

  • Package harness (pnpm test:packages): every one of the 652 spec examples has its own it() block, rendered through renderMarkdownHtml and compared byte-for-byte to the spec HTML, honoring the package ledger (packages/parser-grammar-markdown/src/spec/expectations.json).
  • Repo-level aggregate (pnpm test:curated-suites, see ADR 0034): one aggregate assertion runs the same oracle over all 652 examples so a single pnpm test:repo-gate validates toml-test, xmlts, and CommonMark together. Any example whose outcome contradicts the ledger fails the aggregate.

The ledger currently carries 0 expect-fail and 0 skip entries: 652/652 pass.

The Markdown serializer (serializeMarkdown) was delivered in phases MD-S1 through MD-S4. All CommonMark and GFM features roundtrip correctly: parse → serialize → re-parse produces AST-identical trees.

PhaseFeaturesTests
MD-S1Leaf blocks (thematic breaks, code blocks, HTML)1,841
MD-S2Headings, paragraphs, inline formatting1,864
MD-S3Links, images, blockquotes, lists1,880
MD-S4GFM tables, character escaping, golden roundtrip1,898
SuiteTestsPassedFailed
CommonMark 0.31.26526520
GitHub Flavored Markdown6486480
Total1,3001,3000

The docs/MARKDOWN_GAPS.md ledger in the repository is a frozen Phase 1 pre-flight triage (snapshot 2026-05-01) that predates the completed CommonMark and GFM work; it does not reflect current results.

All 652 CommonMark 0.31.2 spec examples pass. Covered sections include:

SectionExamples
Thematic breaks19
ATX headings16
Setext headings26
Indented code blocks12
Fenced code blocks29
HTML blocks44
Link reference definitions27
Paragraphs8
Block quotes25
List items48
Lists26
Backslash escapes13
Entity references12
Code spans17
Emphasis and strong emphasis131
Links68
Images22
Autolinks19
Raw HTML21
Hard line breaks15
Soft line breaks2
Textual content1

All 648 GFM-specific examples pass. GFM extensions covered:

ExtensionStatus
TablesImplemented
Task list itemsImplemented
StrikethroughImplemented
Autolinks (extended)Implemented
Disallowed raw HTMLImplemented

GFM extensions are enabled by default in parseMarkdown. Pass { gfm: false } for strict CommonMark-only parsing.

The Markdown grammar is linear-time on large inputs. Four quadratic pathologies were mitigated in a single performance run, all behavior-identical:

  • Extended-autolink email fallback: the inline loop skips the email fallback entirely when the inline text has no @, and resolves the residual with-@ case through a once-per-inline-text nextAt table plus a deadAt memo (amortized O(1) per boundary).
  • Multi-line paragraph byte offsets: the per-lookup segment-slice scan is replaced by a precomputed byteAt table plus a breakByteOverrides map (one O(n) build, 4 bytes per char, multi-line paragraphs only).
  • Document gap fill: fillDocumentGaps builds the node array in a single forward pass instead of splicing O(gaps x n).
  • Container close: closeContainersTo rescans only the fresh region between a container and the previously closed inner container, carrying the inner max end forward.

The regression guard packages/parser-grammar-markdown/src/large-file-robustness.test.ts runs four adversarial fixtures (one per pathology) asserting a < 2000 ms 1x parse, a < 3.5 2x/1x scaling ratio, emitSource byte round-trip, and no parse errors.

CommonMark 0.31.2 specification
RAG: commonmark_docs::spec@0.31.2

GitHub Flavored Markdown specification
RAG: gfm_docs::spec@gfm-0.29.0

pnpm conformance:suite measured this family over the test_files/md corpus on 2026-10-06 at Lanexio™ Parser version 1.0.0:

familyvalidinvalidrawcontract-subsetREAL-DEFECT
markdown10800899.9%100.0% (10800/10800)0

The raw figure is below 100.0% because the directory rule classifies 8 inputs as invalid; the contract-subset over the 10,800 valid inputs is 100.0%.