Skip to content

markdown: render hard line breaks instead of concatenating lines - #2945

Merged
huacnlee merged 2 commits into
longbridge:mainfrom
kossoy:fix/hard-break-parse-paragraph
Sep 4, 2026
Merged

markdown: render hard line breaks instead of concatenating lines#2945
huacnlee merged 2 commits into
longbridge:mainfrom
kossoy:fix/hard-break-parse-paragraph

Conversation

@kossoy

@kossoy kossoy commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

parse_paragraph has no arm for Node::Break, so a CommonMark hard break — two
trailing spaces or a backslash — is silently dropped and the adjacent lines are
joined.

Reproduction

Owner: Jane, ID: 338673110  
Persona: assistant

Renders as …ID: 338673110Persona: assistant on one line. Expected two lines.

Measured on a 3 874-note vault: hard breaks appear in the source of a meaningful
share of notes, and every one of them rendered wrong.

Fix

Mirror the inline-HTML <br> path: emit a newline inline node for Node::Break.
Seven lines, crates/base/src/text/format/markdown.rs only.

Note this is a hard break fix. Soft breaks (a plain newline inside a Text
node) are a separate, opposite defect — they render as hard breaks — and are a
separate PR, since the two are distinguishable in mdast and should stay so.

kossoy and others added 2 commits September 4, 2026 09:50
Cover both CommonMark spellings of a hard break — two trailing spaces
and a trailing backslash — so the `Node::Break` arm cannot be dropped
again without a test failing. Verified by removing the arm: the test
fails with 2 children instead of 3.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DJzGY5rMeCxE2r5L6MFzAS
@huacnlee
huacnlee enabled auto-merge (squash) September 4, 2026 10:39
@huacnlee
huacnlee merged commit c3937a3 into longbridge:main Sep 4, 2026
9 checks passed
@huacnlee

huacnlee commented Sep 4, 2026

Copy link
Copy Markdown
Member

Thanks.

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