Skip to content

feat(mdxish): preserve blank line spacing in rendered output#1415

Draft
maximilianfalco wants to merge 2 commits intonextfrom
falco/remove-br-tags-in-favour-of-newline-chars-in-new-editor
Draft

feat(mdxish): preserve blank line spacing in rendered output#1415
maximilianfalco wants to merge 2 commits intonextfrom
falco/remove-br-tags-in-favour-of-newline-chars-in-new-editor

Conversation

@maximilianfalco
Copy link
Copy Markdown
Contributor

@maximilianfalco maximilianfalco commented Mar 31, 2026

🎯 What does this PR do?

See this monorepo PR: https://github.com/readmeio/readme/pull/18047

The markdown parser collapses multiple blank lines between block elements into a single paragraph break, so extra vertical spacing in the source is lost. This PR restores that spacing so the rendered output matches what the author intended.

  • Add remarkRestoreBlankLines remark plugin that detects position gaps in the mdast tree where blank lines were collapsed, and re-inserts empty paragraph nodes
  • Add rehypeEmptyParagraphsToBr rehype plugin that converts those empty <p> elements (invisible due to margin collapse) into <br> elements for visible spacing
  • Wire both plugins into the mdxish pipeline

🧪 QA tips

  • Write markdown with multiple blank lines between paragraphs, headings, lists, and code blocks — verify the extra spacing renders visibly
  • Verify a single blank line (normal paragraph break) does NOT produce extra <br> elements
  • Verify content inside tables, callouts, and other magic blocks is unaffected

📸 Screenshot or Loom

essentiall just stop squashing multiple \n into a single \n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant