Skip to content

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

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

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 browser tests and three round trip cases (a heading, list items, a paragraph below a check list item). They fail without the fix.
  • The Node tests and the browser tests (Chromium, Firefox, WebKit) pass.

Notes

Summary by CodeRabbit

  • Bug Fixes
    • Improved Markdown conversion for hard breaks in headings and list items, including cases with backslashes.
    • Fixed indentation of continuation paragraphs in nested and multiline list items to preserve formatting during conversion.
  • Tests
    • Added coverage for hard breaks and nested list-item formatting across Markdown parsing and round-trip conversion.

@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 Error Error Nov 25, 2026 8:27am UTC
blocknote-website Error Error Nov 25, 2026 8:27am 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 preserves hard breaks in headings and list items as <br> markup. It also indents every line of continuation paragraphs in regular and toggle list items. Added tests and fixtures cover hard breaks, backslashes, and multiline list content.

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.browser.test.ts, tests/src/integration/formatConversion/exportParseEquality/exportParseEqualityTestInstances.ts
Heading and list-item hard breaks are serialized as <br> markup. Backslashes immediately before a break are doubled. Tests and round-trip fixtures cover headings and multiple list types.
List-item continuation indentation
packages/core/src/api/exporters/markdown/htmlToMarkdown.ts, tests/src/integration/formatConversion/exportParseEquality/exportParseEqualityTestInstances.ts, tests/src/integration/formatConversion/parse/parseTestInstances.ts
Continuation paragraphs in regular and toggle list items now indent each content line. Fixtures cover nested multiline content and indented continuation text.

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

Change: Bug fix

Possibly related PRs

  • TypeCellOS/BlockNote#3385: Changes Markdown hard-break parsing, which reads the <br> markup emitted by this PR.
  • TypeCellOS/BlockNote#3392: Changes hard-break trimming and serialization for headings and list items, which intersects with this PR’s hard-break output.
Merge Risk: Minimal · up to bc4ce · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix and its scope: a line break in a heading or list item is kept within its block during markdown export. The raw summary confirms the change converts hard breaks to
in headi…
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.
Description check Passed The description has a clear summary, a testing section, and notes. It explains the problem (a heading or list item with a hard break is read back as two blocks), the fix (writing the break as a
t…
Full details: Title check

Explanation

The title names the fix and its scope: a line break in a heading or list item is kept within its block during markdown export. The raw summary confirms the change converts hard breaks to <br> in headings and list items, which matches the title. The title is specific and does not cover the nested-paragraph indentation change, which is an expected omission.

Full details: Description check

Explanation

The description has a clear summary, a testing section, and notes. It explains the problem (a heading or list item with a hard break is read back as two blocks), the fix (writing the break as a <br> tag on the same line), and the scope (paragraphs in list items keep the backslash form and gain indentation). It also states the stacking dependency on #3385. The template sections Rationale, Impact, Screenshots/Video, and the Checklist are missing or not filled in. The Testing section lists test counts and results but does not say how a reviewer should run them. These gaps are non-critical, so the description is mostly complete.

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 lines within the stream.
List lines tuck beneath their cue,
Backslashes keep their place there too.
Round-trip paths go hopping through.

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: cd27474e-610d-421c-8402-aa2bd3143b60
Commits

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

Files ignored due to path filters: 4

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

  • packages/core/src/api/exporters/markdown/htmlToMarkdown.browser.test.ts
  • tests/src/integration/formatConversion/exportParseEquality/exportParseEqualityTestInstances.ts
  • tests/src/integration/formatConversion/parse/parseTestInstances.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 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: bc4ce44

@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-25 08:40 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.
@YousefED
YousefED force-pushed the fix/markdown-line-break-in-heading-list-item branch from aeb6bfb to bc4ce44 Compare November 25, 2026 08:22
@YousefED
YousefED marked this pull request as draft November 25, 2026 08:22
@YousefED
YousefED marked this pull request as ready for review November 25, 2026 08:33

This branch had an error being deployed

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