Skip to content

fix(core): keep a line break in a heading or a list item in its block in markdown - #3394

Draft
YousefED wants to merge 1 commit into
fix/markdown-parser-fixesfrom
fix/markdown-line-break-in-heading-list-item
Draft

YousefED wants to merge 1 commit into
fix/markdown-parser-fixesfrom
fix/markdown-line-break-in-heading-list-item

Conversation

@YousefED

@YousefED YousefED commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A heading or a list item with a line break (Shift+Enter) exported to markdown that the parser reads back as two blocks. In markdown, the text of a heading and the first line of a list item must be on one line.

The export now writes such a line break as a <br> tag on the same line: * one<br>two. The parser already reads that tag as a line break. A paragraph that is a child of a list item keeps the backslash form, and its lines after a line break now get the indent of the list item.

Testing

  • Three new unit tests and three round trip cases (a heading, list items, a paragraph below a check list item). They fail without the fix.
  • The unit and format tests pass. No browser run was made locally.

Notes

Summary by CodeRabbit

  • Bug Fixes

    • Markdown export now preserves hard breaks and preceding backslashes in headings and list items. Continuation lines in list content, including nested content, are indented consistently.
  • Tests

    • Added round-trip coverage for hard breaks in headings, nested and top-level lists, and checklist items. Added parsing coverage for indented continuation lines in ordered and unordered lists.

@vercel

vercel Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
blocknote Ready Ready Preview Nov 22, 2026 6:43pm UTC
blocknote-website Ready Ready Preview Nov 22, 2026 6:43pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Markdown exporter now represents hard breaks in headings and list-item text as same-line <br> tags. It also indents every line of continuation paragraphs in list items. New tests cover Markdown round trips and parsing of these cases.

Changes: Markdown export

Layer / File(s) Summary
Same-line hard-break serialization
packages/core/src/api/exporters/markdown/htmlToMarkdown.ts, packages/core/src/api/exporters/markdown/htmlToMarkdown.test.ts, tests/src/unit/core/formatConversion/exportParseEquality/exportParseEqualityTestInstances.ts
Heading and list-item hard breaks are serialized as same-line <br> tags. A backslash immediately before a hard break is doubled. Tests cover headings and bullet, numbered, checklist, toggle, and nested list items.
List-item continuation indentation
packages/core/src/api/exporters/markdown/htmlToMarkdown.ts, tests/src/unit/core/formatConversion/parse/parseTestInstances.ts
Continuation paragraphs in regular and toggle list items indent each content line. A parse fixture covers indented text after unordered- and ordered-list items.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

Suggested reviewers: nperez0111

Merge Risk: Minimal · up to aeb6b

This change keeps line breaks in headings and list items inside their block when markdown is exported and read back. No concrete merge-blocking risk was found. Merge it after the base PR it is stacked on.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: keeping a line break inside a heading or list item in Markdown export. The raw summary and objectives confirm the export now writes the break as a
tag on the same…
Description check Passed The description follows the template sections: Summary, Rationale, Changes, Impact, Testing, Screenshots/Video, Checklist, and Additional Notes. The Summary explains the problem and fix. Testing lists…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: keeping a line break inside a heading or list item in Markdown export. The raw summary and objectives confirm the export now writes the break as a <br> tag on the same line, so the title matches the changeset. It is specific and scoped to core, with no vague wording.

Full details: Description check

Explanation

The description follows the template sections: Summary, Rationale, Changes, Impact, Testing, Screenshots/Video, Checklist, and Additional Notes. The Summary explains the problem and fix. Testing lists the new unit tests and round-trip cases and states they fail without the fix. The description does not include a separate Rationale, Changes, or Impact section. Screenshots/Video and the Checklist are absent. The Notes section covers the stacked PR and an alternative approach.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit hops where hard breaks gleam,
&lt;br&gt; keeps each line in the stream.
List lines tuck in, aligned and neat,
Round trips bring the text complete.
The rabbit nibbles, pleased to see,
Markdown flow as it should be.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 476412d1-fb80-4ffe-8254-5113e7aadd1a
Commits

Reviewing files that changed from the base of the PR and between d4bdd9a and aeb6bfb.

Files ignored due to path filters: 4

  • tests/src/unit/core/formatConversion/exportParseEquality/__snapshots__/markdown/markdown/hardBreakBelowCheckListItem.json is excluded by !**/__snapshots__/**
  • tests/src/unit/core/formatConversion/exportParseEquality/__snapshots__/markdown/markdown/hardBreakInHeading.json is excluded by !**/__snapshots__/**
  • tests/src/unit/core/formatConversion/exportParseEquality/__snapshots__/markdown/markdown/hardBreakInListItems.json is excluded by !**/__snapshots__/**
  • tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/listItemIndentedTextLine.json is excluded by !**/__snapshots__/**
Files selected for processing: 2

  • packages/core/src/api/exporters/markdown/htmlToMarkdown.ts
  • tests/src/unit/core/formatConversion/exportParseEquality/exportParseEqualityTestInstances.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@pkg-pr-new

pkg-pr-new Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/@blocknote/ariakit@3394

@blocknote/code-block

npm i https://pkg.pr.new/@blocknote/code-block@3394

@blocknote/core

npm i https://pkg.pr.new/@blocknote/core@3394

@blocknote/diagram-block

npm i https://pkg.pr.new/@blocknote/diagram-block@3394

@blocknote/mantine

npm i https://pkg.pr.new/@blocknote/mantine@3394

@blocknote/math-block

npm i https://pkg.pr.new/@blocknote/math-block@3394

@blocknote/react

npm i https://pkg.pr.new/@blocknote/react@3394

@blocknote/server-util

npm i https://pkg.pr.new/@blocknote/server-util@3394

@blocknote/shadcn

npm i https://pkg.pr.new/@blocknote/shadcn@3394

@blocknote/xl-ai

npm i https://pkg.pr.new/@blocknote/xl-ai@3394

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/@blocknote/xl-docx-exporter@3394

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/@blocknote/xl-email-exporter@3394

@blocknote/xl-multi-column

npm i https://pkg.pr.new/@blocknote/xl-multi-column@3394

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/@blocknote/xl-odt-exporter@3394

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/@blocknote/xl-pdf-exporter@3394

@blocknote/xl-typst-exporter

npm i https://pkg.pr.new/@blocknote/xl-typst-exporter@3394

commit: aeb6bfb

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.2

QR code for preview link

🚀 View preview at
https://TypeCellOS.github.io/BlockNote/pr-preview/pr-3394/

Built to branch gh-pages at 2026-11-22 19:05 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

…ist item in its block

The markdown export wrote each hard break as a backslash and a newline.
A heading is one line, so the parse made a new paragraph from the text
after the break. In a list item, the parser does not read the line
after the break as text of the item: it makes a child paragraph of it,
or a new paragraph if the line has no indent.

The export now writes a hard break in the text of a heading or a list
item as a `<br>` tag, so the text stays on one line. The markdown
parser reads this tag as a hard break already. Backslashes directly
before the tag are doubled, so that they do not escape it.

A paragraph that is a child of a list item keeps the backslash form.
The export now indents its lines after a hard break, so the parser
reads them as a part of that paragraph.

The parser is not changed.

This branch was successfully deployed

2 active deployments
Preview – blocknote-website — aeb6bfbf Deployed Nov 22, 2026 by vercel[bot]
Preview – blocknote — aeb6bfbf Deployed Nov 22, 2026 by vercel[bot]
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