A markdown parser for Obsidian: the write-up
A report for the Obsidian team on obsidian-markdown-parser: what it set out to do, what it does, measured against the current Obsidian 1.15.1 oracle pin (with earlier measurements dated below), what it does not do yet, where its code comes from, and the terms it is offered on. Each section links the page that holds the details and the numbers.
The repository is public, with the Obsidian team’s permission. Nothing in it has been published to npm yet.
In short
Section titled “In short”- The editor’s classes are reproduced exactly. All 46,508 documents of eleven fuzzed corpora get the live editor’s class on every character and line. Swapped in as the editor’s language inside Obsidian, the parser gives 0 class differences from the stock language on 116 notes, and live preview draws the same widgets.
- Live parsing works for the editor. The tokenizer resumes from any line outside a fenced block or a script or style element, and after an edit it takes the old tree back once its state matches the old parse. An edit at the start of a 100,000-line document re-parses to the end in under 1 ms. Inside Obsidian 1.15.1 a full parse of a long note is 8 to 10% faster than the stock language’s, and a keystroke costs about the same as the stock one, in live preview too.
- The metadata worker’s
CachedMetadatais reproduced exactly, as JSON with key order, on every document measured: 3,743 run through the worker offline, the live app’s metadata of all 674 spec examples, and 115 vault notes inside Obsidian. - The Obsidian syntax is defined once and ships for
@lezer/markdown, micromark with mdast, and markdown-it, each checked against one conformance corpus and the CommonMark 0.31.2 suite. - It is three engines, not the single Lezer parser asked for. Each of Obsidian’s three outputs comes from a different kind of parser today, and each engine here is that kind of parser. What one engine would take is costed below, and it turns on one question for the team.
The goals
Section titled “The goals”The goals came from the founder (2026-10-13):
- One incremental parser on
@lezer/markdownthat could serve both the editor and the reading view. - Live parsing of a changing document: efficiency, partial states and resume points.
- CSS-class compatibility. The editor’s classes come from a CodeMirror 5 token grammar, and themes and custom CSS depend on them, so a new parser has to give the same classes or every theme breaks.
Four more were added on top of those:
- One definition of the Obsidian syntax, with one conformance corpus measured against Obsidian, shipped for the three main JavaScript markdown ecosystems: Lezer first, then micromark and mdast, then markdown-it.
- CommonMark and GFM conformance in each of them, with Obsidian’s departures from the spec as options.
- The reading view’s parse and the metadata worker’s
CachedMetadatafrom the same work, checked against the worker. - A way to keep up with Obsidian: every claim pinned to one version, and one command to re-check it against the next.
How it was measured
Section titled “How it was measured”Nothing here is matched to a description of Obsidian’s behaviour. It is matched to Obsidian itself, through oracles read from a running app (oracles.md):
- The editor’s classes, read from the live editor’s syntax tree over the Chrome DevTools Protocol, for fuzzed documents built from pieces of every construct.
- The metadata worker’s
CachedMetadata, read live, and offline by running the app’s ownworker.json generated documents. - The reading view’s DOM, for every CommonMark and GFM spec example and 169 probes of where Obsidian departs from the spec.
Desktop oracles are pinned to Obsidian 1.15.1; Android remains independently pinned to 1.14.4. The pin lives in one place, and npm run oracle:refresh re-reads every oracle from another version, then reports what changed and whether the parser still matches. Its first run re-read 1.14.4 itself: 0 of the documents both reads hold changed, so a change on a new version is that version’s. Its run on the 1.15.0 insider build found two new rules for the editor’s formatting marks and nothing else, and the tokenizer now takes the Obsidian version whose classes it gives. Its run on the public 1.14.5 found 0 changed readings, so the pin moved to it from 1.14.4.
The complete public 1.15.0 refresh on 2026-11-03 found 6,622 changed readings, all editor classes or Source/Live Preview DOM, and no new parser regression. Metadata and Reading-view outputs were unchanged. All 162 conformance and supplemental link/name tests passed on its files with one worker. The release differential moved no family or count: 9,626 mode-judge findings over 50,466 documents and 173 live-surface findings over 400 notes on each version. The superseded desktop 1.14.5 files were removed after the full suites passed (oracles.md).
The complete public 1.15.1 refresh on 2026-11-13 found 5,360 changed readings and no new parser regression. The editor’s classes did not change at all. The metadata worker adds a format version, v: 1, to every document and reads a front matter key hasOwnProperty it used to throw on, and parseMetadata takes the Obsidian version to follow both. The Reading view sanitizer now drops an inline processing instruction and keeps a <search> element. The release differential moved no mode-judge family, and one live-surface finding of editor-reformats-table went away. All 674 tests passed on the 1.15.1 files with one worker, and the desktop pin moved to them (oracles.md).
Results per goal
Section titled “Results per goal”1. One Lezer parser for the editor and the reading view: partly
Section titled “1. One Lezer parser for the editor and the reading view: partly”There are three engines (architecture.md):
| Engine | Gives | Exact against |
|---|---|---|
A port of the editor’s CodeMirror 5 line tokenizer, hosted as a Lezer Parser |
the editor’s classes, as a CodeMirror 6 Language |
the live editor |
@lezer/markdown with the Obsidian syntax as extensions |
the syntax tree, and the same syntax for micromark and markdown-it | the conformance corpus and the spec suites |
A port of remark-parse 8 with Obsidian’s edits to three of its block tokenizers |
the reading view’s parse and HTML, and CachedMetadata |
the reading view and the metadata worker |
Each output is exact because it comes from the same kind of parser Obsidian uses for it. The classes are the artefacts of a stateful line tokenizer: inline styles with no lookahead that run across blocks, fences that ignore their container, list indentation numbered by history. Phase 0 measured how far a @lezer/markdown tree with a mapping gets towards them: 28.8% of documents exact, against 100% for the ported tokenizer (phase-0.md). The reading view and the worker run remark-parse 8, whose block structure and inline algorithm differ from @lezer/markdown’s in places no extension point reaches.
So the realistic single-engine target is two Lezer parsers: the class tokenizer, which already is one, and one @lezer/markdown tree for everything else. Getting the metadata and the reading view from that tree means putting remark-parse 8’s block structure and inline rules inside @lezer/markdown, unless today’s reading of malformed input may change. That is the question for the team below.
2. Live parsing: yes for the editor, not yet for the metadata
Section titled “2. Live parsing: yes for the editor, not yet for the metadata”The CodeMirror 6 host (cm6-host.md) parses in chunks that record the tokenizer state, resumes after an edit from the last chunk the edit cannot have changed, and reuses the old chunks after the edit once a line ends in a state equal to the old parse’s at the same text. Measured with scripts/demo/cm6-bench.ts:
| Lines | Full parse | Edit at the start, re-parse to the end |
|---|---|---|
| 10,000 | 49.9 ms | 0.95 ms |
| 100,000 | 172.2 ms | 1.29 ms |
Before the reuse, the second column was 19.8 ms and 100.6 ms, on texts read before the corpus gained its last three piece sets, which cost about half as much to parse in full. An edit that changes the state of every line after it, such as opening a fence, still costs a parse to the end. 9,900 random edits across all eleven corpora gave the same tree as a fresh parse.
Inside Obsidian, with the parser swapped in as the editor’s language (demo-plugin.md), on a 100,001-line note:
| Mode | Full parse, parser | Full parse, stock | Keystroke, parser | Keystroke, stock |
|---|---|---|---|---|
| Source | 882 ms | 985 ms | 1.8 ms | 2.8 ms |
| Live preview | 927 ms | 1,009 ms | 28.4 ms | 26.0 ms |
Measured on Obsidian 1.15.1 on 2026-11-24, on an idle machine.
Live preview walks the whole tree on every keystroke and splits every node’s classes, so its keystroke follows the tree’s length and how cheaply its class strings split. A first run gave 87.9 ms against 29.4 ms, until the re-parse stopped at the viewport, as the stock one does, and the class strings were internalized (demo-plugin.md).
The metadata is not incremental: parseMetadata parses the whole note on every call. Its peak memory grows with the note’s length: 250 MB of process memory for the 100,000-line note in Node, 82 MB of it the remark-parse tree.
3. CSS-class compatibility: yes
Section titled “3. CSS-class compatibility: yes”- 46,508 of 46,508 documents exact, in eleven oracle corpora covering tables, HTML blocks, 30 fenced languages through their CodeMirror 5 modes, nested lists, markdown nested in markdown fences, code spans left open and highlight color markers.
- Inside Obsidian, 0 class differences on 116 notes and 282,354 stock nodes. Obsidian’s renderer reads two node props of its own, which the language fills in when given them, so themes, live preview, folding, task checkboxes, callouts and code-block flair all work on the parser’s tree.
- The tree is identical node for node, type names and merged tokens included, on all 46,508 documents and inside Obsidian on all 116 notes, so the same text renders as the same spans. On the spec examples, every tree whose classes match the editor’s matches it node for node too.
4. One syntax for three ecosystems: yes
Section titled “4. One syntax for three ecosystems: yes”The syntax is defined once (src/syntax/spec.ts): internal links and embeds, tags, %% comments, math, highlights, footnotes with inline notes, block ids, callouts, task markers and front matter (syntax.md). Each adapter passes the whole conformance corpus. On the 29,596 documents of seven oracle corpora, compared with the Lezer tree node for node:
| Adapter | Same Obsidian nodes as the Lezer tree |
|---|---|
| micromark and mdast | 28,551 of 29,596 |
| markdown-it | 28,681 of 29,596 |
None of the differences is a rule of the Obsidian syntax. Each is a place where two parsers’ block structure reads the document differently, an unclosed block taking the document’s last line break, which GFM table rules apply, and which list items may interrupt a lazy line, or where they pair a highlight’s == across emphasis differently.
5. CommonMark and GFM: yes, with Obsidian’s departures as options
Section titled “5. CommonMark and GFM: yes, with Obsidian’s departures as options”Every adapter takes a preset (commonmark, gfm, obsidian) with any flag overridden (spec-suites.md):
| Adapter | CommonMark 0.31.2 | GFM extension examples |
|---|---|---|
@lezer/markdown |
651 of 652 | 21 of 22 |
| micromark | 652 of 652 | 21 of 22 |
| markdown-it | 652 of 652 | 13 of 22 |
The reading view departs from the spec on 211 of the 674 examples, each explained and pinned by a test. Eleven of the rules behind them are flags of ObsidianQuirkFlags, off in every preset: ten in every adapter, and list item continuation in micromark and markdown-it only, since @lezer/markdown keeps it internal. The rest are remark-parse 8’s own inline algorithm and container handling, which no adapter’s extension points reach, so they come from the fourth engine instead.
The help names CommonMark and GFM but no version of either, so a departure is measured here against CommonMark 0.31.2, the current release, and not against a version Obsidian states it follows. Naming the versions in the help is proposed in obsidian-help#1158.
6. The reading view’s parse: yes
Section titled “6. The reading view’s parse: yes”The remark-parse 8 port gives the same tree, positions included, as npm remark-parse 8.0.3 with Obsidian’s three tokenizers on 240,843 documents, and the reading view’s HTML on every spec example in the quirk and syntax rows but five that the browser or the sanitizer changes after the parse, and on all 68 probes of the inline departures (remark.md).
7. CachedMetadata: yes
Section titled “7. CachedMetadata: yes”parseMetadata gives the worker’s whole CachedMetadata, equal as JSON with key order: headings, links and embeds, the markdown links the worker counts, tags, footnotes, reference definitions, list items, sections, block ids, and front matter, or null where the worker throws (metadata.md). It is pinned to 3,743 worker documents and the live app’s metadata of all 674 spec examples, and outside the repository it gave 0 differences on 180,000 more fuzzed documents. Inside Obsidian it matched the metadata cache on all 116 notes, the 100,001-line note included, in 646 ms for all of them.
It is no longer faster than the worker. Timed offline against the workers of 1.14.5, 1.15.0 and 1.15.1 on 2026-11-11, it gives each one’s metadata on every text, lists and quotes nested 600 deep included. 1.15.1 adds only a format version, v: 1. It was about as fast as the 1.14.5 and 1.15.0 workers. The 1.15.1 worker, with the team’s remark optimization, is far faster than all of them: 321 ms on the 100,001-line note, where parseMetadata takes 7.3 s, and 1.5 s on 10,000 unclosed emphasis openers, where it takes 41 s. These are single runs on a loaded machine (demo-plugin.md).
The engine was then made linear where it grew faster than the text, and cheaper per character, with the metadata unchanged. Timed again on 2026-11-11, on a machine still loaded, it beats the 1.15.1 worker on the nested lists, unclosed emphasis openers and brackets, and the reference title: 10,000 unclosed emphasis openers take 208 ms where the worker takes 7.9 s. It was then still 1.6 to 6 times slower on the vault notes, the backtick runs, the wikilinks, the nested quote and the long footnote (demo-plugin.md). A second round, timed on 2026-11-12, made the long footnote 4 times faster than the worker. It brought the other four to between 1.2 and 1.8 times the worker’s time: 1.2 on the nested quote, 1.3 on the wikilinks, 1.4 on the backtick runs and the 10,000-line note, and 1.3 to 1.8 on the 100,000-line note (demo-plugin.md). Measured on an idle machine on 2026-11-24, those four rows are 1.2 to 1.5 times the worker’s best time, and the 10,000-line note ties it by median (demo-plugin.md). So this write-up does not claim the metadata engine is faster than the worker on ordinary notes. It is faster on the nested lists, the unclosed emphasis openers and brackets, and the long definitions, where the worker grows faster than the text.
8. Keeping up with Obsidian: yes
Section titled “8. Keeping up with Obsidian: yes”npm run oracle:refresh -- --obsidian-version <version> reads every oracle from that version beside the pinned ones, and npm run oracle:drift reports per oracle the readings that changed and whether the parser matches them, then runs the conformance suites on the new files (oracles.md). Moving the pin to a new version means fixing what the report shows, then changing one constant and re-recording the scores that name the old files.
Known gaps
Section titled “Known gaps”Each is measured, and each has a test or a script that reproduces it.
In the editor engine
Section titled “In the editor engine”- 13 of the 674 spec examples differ in the editor’s classes, confirmed on the former 1.14.5 and 1.15.0 pins and the current public 1.15.1 pin (661/674 agree).
In the metadata engine
Section titled “In the metadata engine”parseMetadatais not incremental, so it re-parses the whole note on every change.
In the Lezer tree and the adapters
Section titled “In the Lezer tree and the adapters”@lezer/markdown1.8 differs from CommonMark 0.31.2 in seven examples. Six are worked around here. Example 280, a list item that starts with a blank line, sits in its internal list continuation and cannot be. All seven are reported upstream as lezer/markdown#70, without naming this project.- The adapters differ from the Lezer tree on 1,045 and 915 of 29,596 documents, block structure and the pairing of highlights across emphasis (goal 4).
- With every flag on, each adapter matches the reading view on 34 of the 68 inline probes. The other 34 are
remark-parse8’s inline rules, which only the fourth engine has. - The editor and the worker read the syntax differently in 9 of the conformance corpus’s cases: a link holding a
], a run of three or more=and a==before>in a highlight, links and tags inside comments, an inline comment closing on its line, a%%line interrupting a paragraph, a footnote reference with no definition, and a footnote definition inside a quote (remark.md). The tree follows the editor and the metadata follows the worker. - List indentation beyond CommonMark’s is not yet measured: whether Obsidian nests a child indented by 2 or 3 spaces where CommonMark needs the content column, and the same with tabs.
In the architecture
Section titled “In the architecture”- No
CachedMetadataprojection from the@lezer/markdowntree exists yet, so the cost of a single engine is known on the spec examples and probes only. The next step is that projection, scored against the worker oracle with each differing document put down to its cause (architecture.md).
Questions for the team
Section titled “Questions for the team”- How much of today’s reading of malformed input has to stay exact? If the reading view and the metadata may change where
remark-parse8’s reading is an artefact rather than markdown, such as emphasis across a code span or a link inside a link, the single@lezer/markdowntree is within reach, with the flags the adapters already have. If they must stay exact, theremark-parse8 engine is the cheaper way to keep them so. - Which grammar of the syntax wins where the editor and the worker disagree? Today a note can show a link in the editor that the metadata does not count. One parser for both would have to pick.
- Which spec versions does Obsidian target? Reading view and the worker run
remark-parse8, which predates CommonMark 0.30, and the editor’s CodeMirror 5 mode follows no versioned spec. A stated target is what makes a departure a checkable claim, and it is asked publicly in obsidian-help#1158. - What would the team want it measured against next: a newer Obsidian, a larger real vault, mobile, or a theme set?
Where the code comes from
Section titled “Where the code comes from”(provenance.md, THIRD-PARTY-NOTICES.md)
- No code of the Obsidian app is in the repository, and none has ever been committed. The full history was checked for every file it ever added.
- The app’s code was read, so this is not a clean room in the strict sense: the editor’s mode and the CodeMirror 5 fork, for rules the class oracle could not settle, and
worker.js, for whichremark-parsetokenizers were edited, the plugin chain that adds the syntax and the walk toCachedMetadata. Every rule taken from it was written fresh and then measured against the running app. Each part’s page says whether it was read. - Open-source code is ported under its license: CodeMirror 5’s
markdownmode and HyperMD,remark-parse8.0.3 and its helpers, and parts of micromark, markdown-it and@lezer/markdown, all MIT, with the CommonMark and GFM spec examples under CC-BY-SA 4.0. - The oracle files hold the app’s output on documents the repository generated: class names,
CachedMetadataand rendered HTML. No code. The offline worker oracle loadsworker.jsfrom an Obsidian install at run time and keeps nothing of it. - It was written with AI coding tools, under my direction.
This is offered to Obsidian as a gift.
- If the team takes it into the core, I will sign a written assignment of my copyright in the repository at an agreed commit, with the third-party components left under their own licenses. A draft is ready.
- Until then it stays private. It is not published, packaged to a registry or mentioned anywhere public, and that changes only with the team’s permission.
- Access is a GitHub invitation to the private repository, or an archive of it, whichever the team prefers.
- Help with the hand-over is part of the offer: walking through the code, moving the oracles to a new Obsidian, or measuring whatever the team asks.
Running it
Section titled “Running it”From a clone, with Node 22 or later:
npm installnpm test # every suite, the oracle checks includednpm run build # both packages, into dist/lib/ and packages/metadata/dist/- The demo plugin:
npx jiti scripts/demo/build-demo-plugin.ts, then copydist/demo-plugin/into a test vault as.obsidian/plugins/markdown-parser-demo/and enable Markdown parser demo. Its commands swap the parser in and out of every editor, compare the classes and the metadata with the app’s own, and time a full parse and 50 keystrokes (demo-plugin.md). - The same, unattended on a vault:
npx jiti scripts/demo/demo-plugin-measure.ts [--vault <dir>] [--lines <n>]. - The oracles against another Obsidian:
npm run oracle:refresh -- --obsidian-version <version>(oracles.md). - The oracles as test cases for your own suites:
npm run export:test-caseswrites the spec examples, the quirk probes and the metadata worker documents as plain JSON intodist/test-cases/, each spec case with both the spec’s HTML and Obsidian’s, the CommonMark and GFM examples in files of their own, each an-allfile beside a-failingfile of only the examples Obsidian departs on, the quirk probes Obsidian departs on with the HTML of commonmark.js or cmark-gfm, reference implementations that pass their whole spec, plus a sample of notes with all three modes’ HTML as the user sees them, and the notes where the editor (byeditorwe meanSource modeorLive Preview) and Reading view disagree, the forum issues and the 30 new kinds the mode judge found across the oracle corpora (mode-judge.md) and where the metadata cache drops or misplaces data (with the metadata expected), and no code of this parser (oracles.md). - The editor’s cost:
npx jiti scripts/demo/cm6-bench.ts [--lines <n>]. - The metadata’s cost against Obsidian’s worker:
npx jiti scripts/demo/metadata-bench.ts --worker <path to worker.js>.... - The packages and their entry points: api.md.
@mnaoumov/obsidian-markdown-parser-metadatais the metadata alone, with four small dependencies and no editor.
The scripts that read a live Obsidian need obsidian-integration-testing, which launches the app in a throw-away profile and vault.