fix(files): collapse blank-line runs to markdown standard (no empty-paragraph explosion / reflow) - #6198
Conversation
…aragraph explosion / reflow) parseMarkdownToDoc now strips ALL top-level empty paragraphs (leading, interior, trailing), not just trailing. A run of blank lines between blocks is insignificant in markdown (CommonMark collapses it), but @tiptap/markdown reconstructs one empty paragraph per blank line — which made the mounted editor render vertical gaps that exist nowhere else the file is viewed (GitHub, download, our own static preview), let a pathological blank run explode into thousands of empty nodes, and caused the visible reflow on open (static preview collapses empty <p>; the live editor gives each a trailing-break line). Collapsing on parse keeps normal one-blank-line spacing, matches every standard renderer, and stays idempotent so the round-trip-safety probe still reaches a fixed point (files stay editable; existing files normalize on next cold-open + save). Serializer is intentionally NOT changed — a global blank-run collapse there would corrupt blank lines inside fenced code blocks.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview
The
Tests are rewritten around the collapse contract (including a 4,000-newline regression) rather than chunked-vs-whole empty-paragraph parity. Reviewed by Cursor Bugbot for commit e28623b. Configure here. |
Greptile SummaryThe PR normalizes markdown parsing by removing all top-level empty paragraphs and allows blank-line-heavy documents to use the chunked parser, preventing pathological empty-node expansion and editor reflow.
Confidence Score: 5/5The PR appears safe to merge, with parsing, serialization, dirty-state, and collaboration paths converging on the same idempotent blank-line normalization. The changed filter targets only structurally empty top-level paragraphs, context-sensitive markdown constructs retain dedicated handling, and the normalized editor and persistence paths remain consistent.
|
| Filename | Overview |
|---|---|
| apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/markdown-parse.ts | Collapses top-level parser-generated empty paragraphs and routes blank-run documents through the chunked parser while retaining whole-document handling for context-sensitive constructs. |
| apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/markdown-parse.test.ts | Replaces empty-paragraph preservation assertions with normalization, idempotency, line-ending, list-boundary, and 4,000-newline regression coverage. |
| apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/markdown-fidelity.ts | Clarifies that interior blank-run cleanup occurs during parsing rather than serialization to preserve whitespace inside fenced and verbatim content. |
Reviews (1): Last reviewed commit: "fix(files): collapse blank-line runs to ..." | Re-trigger Greptile
Summary
@tiptap/markdownreconstructs one empty paragraph per blank line, andparseMarkdownToDoconly stripped trailing empties — so a pathological blank run (an agent/paste artifact) exploded into ~1,959 empty paragraph nodes baked into the doc.<p></p>collapsed (invisible), but the mounted ProseMirror editor gives each a trailing-break line, so gaps appeared ~0.5s after open.parseMarkdownToDocnow collapses all top-level empty paragraphs (leading, interior, trailing) to standard markdown spacing. A blank run between blocks is insignificant in CommonMark, so this makes the editor render the file the way every other renderer does (GitHub, the download, our own static preview), and neutralizes any pathological source.EMPTY_PARAGRAPH_SPACINGrouting that forced blank-run docs onto the slow O(n²) whole-parse (it existed only to preserve empties we now strip) — blank runs now take the fast linear chunked path; chunked+strip == whole+strip.Type of Change
Testing
Checklist