ReadingResearchRadarInvestment frameworkAI Company Primary Sources
Sign in / Sign up
← Back to reading
NewsMaterial4 min readDisconfirmAI Editorial

ProseMirror Product Developer: Under Tree-Based Document Architecture, Your Markdown Source Is Lost on the First Save

A developer with three years of experience building ProseMirror-based products argues, through a version-by-version review of mainstream Markdown conversion library source code, that when a JSON document tree is the source of truth and Markdown is merely its serialized output, the user's original writing is inevitably altered upon the first save. They propose an alternative approach where the Markdown source itself is authoritative, implemented via CodeMirror 6's decoration system for WYSIWYG editing, providing specific benchmark data on incremental parsing and explaining architectural differences in collaborative editing.

2026-10-29 11:29 GMT+8

A developer with three years of experience working on ProseMirror-related products published a long-form post on V2EX, reviewing the source code of mainstream Markdown conversion libraries version by version. They present an architectural judgment: when the authority of a document lies in its JSON tree and Markdown is merely one way to print it, the source code you wrote is already gone by the time you hit save for the first time.

They cite examples from the most commonly used implementations. prosemirror-markdown 1.13.4 hardcodes italics and bold as asterisks; underline emphasis you write changes after one save. Unordered lists default to asterisks, so your habit of using hyphens disappears. Ordered lists are renumbered, and line-ending double spaces for line breaks are uniformly changed to backslashes. If it encounters syntax it doesn't recognize, it throws an error; the default schema lacks tables, footnotes, and strikethrough. Tiptap's official @tiptap/markdown 3.30 similarly hardcodes bold and italic formatting. Nodes without corresponding renderers output empty strings, causing content to silently disappear. The community-maintained tiptap-markdown has ceased maintenance; when encountering nodes it cannot express, it outputs placeholders. Tables with merged cells degrade to HTML, losing column alignment information.

The author emphasizes these are not bugs but inevitable results of the architecture. Since there is only one printing method, the source code you wrote is already gone upon the first save. This might not matter for personal note-taking, but it is critical for three scenarios: documents stored in Git show full-screen format changes even when modifying a single character; AI modifies only one section but normalizes the writing style of the entire document; the same file needs to be used across VS Code, static site generators, and other Markdown tools.

Sign in / Sign up
ReadingResearchRadarInvestment frameworkAI Company Primary Sources

The author then tests the actual limitations of Markdown syntax itself. Using micromark 4.0.2 with GFM extensions, they tested item by item: table cells can only contain inline content; placing a list or code block inside will break the table immediately. Bold text cannot be nested within inline code, nor can links be nested within links. Chinese punctuation causes bolding to fail—CommonMark determines whether asterisks can start or end emphasis by checking if the surrounding characters are punctuation or whitespace. Chinese quotes and parentheses are punctuation, followed immediately by Han characters, so the rule deems them invalid. English writers rarely encounter this issue, but Chinese writers face it daily.

The author's solution is MSFE (Markdown Source-First Editor), making the Markdown source itself authoritative. Complex blocks store data within code fences, rendering as editable multi-dimensional tables within MSFE, while appearing as plain code segments in GitHub or VS Code that do not break or get lost. Collaborative editing operates on the Markdown source itself—a single Yjs text object. Since any segment of text is valid Markdown, there is no issue of deleting nodes due to structural invalidity.

They implement WYSIWYG using CodeMirror 6 decorations and widgets: headings appear larger, markup symbols are hidden, tables are drawn as tables, and formulas are rendered as formulas, while the underlying text remains unchanged. Three views—the document view, live preview, and source view—are different presentations on the same CodeMirror instance. Switching between them requires no conversion, preserving selection ranges and undo history.

Regarding performance, they provide proof of reuse for Lezer's Markdown incremental parsing. The parser records which intervals are reused verbatim, allowing the editor to skip unchanged parts. For a 1 MiB document with continuous input over 20 iterations, syntax tree visits dropped from 107,760 to 1,380 (a 98.7% reduction); syntax tree comparisons dropped from 153,940 to 660 (a 99.6% reduction). Where proofs fail, the system falls back to full comparison, ensuring correctness is unaffected.

The author explicitly acknowledges the costs of source-first approaches: every input requires updating the syntax tree, making large files slow. MSFE is currently in alpha, and its API is subject to change. The open-source portion is licensed under MIT; commercial components include AI document reading/writing, displaying changes and annotations in a 'pending review' format. They also promote the QuireKit editor ecosystem, including Classic, a page-based document editor based on ProseMirror.

Notable boundaries exist: these performance figures are self-reported benchmarks. The portability of the code fence solution for complex blocks—i.e., whether other Markdown tools can recognize and edit structured data within fences—has not been verified by third parties. The author's core argument (that tree-based authority leads to source loss) is built on reading specific library versions' source code and is verifiable; however, the long-term maintenance costs and ecosystem compatibility of the alternative solution remain open questions.

Sources

  • v2ex.comV2EX↗
Continue researching →