MSFE: A Source-First Markdown Editor Framework That Stops Format Drift
Editor teams keep fighting the same conversion and collaboration bugs. MSFE shows that treating Markdown as the source of truth eliminates formatting drift, keeps Git diffs clean, and makes AI edits precise, while remaining open source and extensible.
Most modern note apps and editors convert Markdown into JSON tree structures, turning Markdown into a print format and rewriting your source on every save. The author ran a three-year deep dive into these conversion losses. MSFE (Markdown Source-First Editor) flips the model: the Markdown source is the document itself. Complex elements like tables and diagrams live inside code fences, which render as interactive widgets in the editor but remain valid code blocks everywhere else. The editor uses CodeMirror 6 with decorations to hide markers and render rich layouts, and three views (document, live, source) are just different presentations of the same text, so switching does no conversion. Collaboration syncs the raw Markdown text over Yjs, avoiding the structural deletions and lost edits seen in y-prosemirror. Performance is handled with incremental parsing that skips unchanged regions, cutting syntax tree work by 98% on large files. The framework is packaged with a Tiptap-style extension API, includes a prebuilt MD Editor, and offers both MIT-licensed exports and commercial template-based Word/PDF output with explicit loss reports.
Source-first design decouples presentation from content: the same Markdown text can appear as WYSIWYG, live preview, or raw source without any transformation, which directly addresses the dual-editor complexity and its lossy conversions.
Storing complex blocks as code fences with structured data is a pragmatic compromise; it preserves the content for external Markdown tools while enabling rich editing inside the fence, but it relies on convention rather than a standard syntax.
The collaboration results suggest that plain-text CRDTs (syncing the Markdown string) avoid the structural conflicts of tree-based CRDTs simply because any text is a valid document; the trade-off is that concurrent edits to the same region may require manual merge, as noted.
The performance numbers on incremental parsing show that editing large Markdown files can be made near-instant, but only with careful parser-level reuse; the approach generalizes to streaming AI output, which the author ties into the same parser.