Skip to content

Preserve single Markdown line breaks in exports#164

Open
spadesmaster wants to merge 5 commits into
bowenliang123:mainfrom
spadesmaster:codex/hard-line-breaks-by-default
Open

Preserve single Markdown line breaks in exports#164
spadesmaster wants to merge 5 commits into
bowenliang123:mainfrom
spadesmaster:codex/hard-line-breaks-by-default

Conversation

@spadesmaster

Copy link
Copy Markdown

What this fixes

Markdown files that rely on single newlines between visible lines, including emoji-led bullets and other non-dash bullet styles, were being rendered as one wrapped paragraph in exported documents. In DOCX/PPTX/PDF/HTML output, those lines were collapsing into spaces instead of staying as distinct lines.

That made valid Markdown look broken in exported documents, especially for lists and summary blocks that intentionally use line-separated entries rather than - bullets.

What changed

  • Enable Pandoc hard_line_breaks by default for DOCX/PPTX/PDF exports
  • Enable nl2br in the HTML conversion path so HTML/PDF retain visible line breaks consistently
  • Add regression tests that verify:
    • DOCX output contains hard breaks for line-separated Markdown
    • HTML output retains <br> elements for the same input
  • Add a simple fixture with line-separated emoji-led lines to cover the real-world case

Why this should be the default

The package already treats these inputs as valid Markdown. The problem was the export layer collapsing visible line separation during conversion. Making hard breaks the default preserves the author’s intended layout across the export paths and keeps Markdown Exporter usable for docs that are not written as dash-based bullet lists.

Notes

  • This applies to the installed CLI and command-driven usage as well, since they share the same export code paths
  • I kept the change scoped to the conversion defaults rather than requiring users to change their source Markdown

@spadesmaster spadesmaster marked this pull request as ready for review May 22, 2026 04:32
@bowenliang123 bowenliang123 self-assigned this Jul 9, 2026
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.

2 participants