fix: Parse new lines in text/plain as line breaks (BLO-1170)#2712
fix: Parse new lines in text/plain as line breaks (BLO-1170)#2712matthewlipski wants to merge 6 commits intomainfrom
text/plain as line breaks (BLO-1170)#2712Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR updates markdown-to-HTML conversion to emit ChangesSoft Break Rendering & Test Updates
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/src/unit/core/formatConversion/parse/parseTestInstances.ts (1)
1129-1135: ⚡ Quick winAdd a focused
doubleNewLinesmarkdown fixture.Given the requirement is “single newline = hard break, double newline = new paragraph,” it’d be good to add one minimal test case dedicated to two consecutive newlines so this behavior doesn’t regress implicitly behind broader fixtures.
Suggested fixture addition
{ testCase: { name: "singleNewLines", content: `Line 1 Line 2 Line 3 Line 4 `, }, executeTest: testParseMarkdown, }, + { + testCase: { + name: "doubleNewLines", + content: `Line 1 + +Line 2 +`, + }, + executeTest: testParseMarkdown, + },🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/src/unit/core/formatConversion/parse/parseTestInstances.ts` around lines 1129 - 1135, Add a focused fixture next to the existing singleNewLines testCase: create a new testCase object named "doubleNewLines" (consistent with the surrounding testCase entries) whose content is two paragraphs separated by exactly two consecutive newlines, e.g. "Line 1\n\nLine 2\n" so the parser is explicitly tested for double-newline → new paragraph behavior; place it near the "singleNewLines" entry so it runs with the same suite.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/src/unit/core/formatConversion/parse/parseTestInstances.ts`:
- Around line 1129-1135: Add a focused fixture next to the existing
singleNewLines testCase: create a new testCase object named "doubleNewLines"
(consistent with the surrounding testCase entries) whose content is two
paragraphs separated by exactly two consecutive newlines, e.g. "Line 1\n\nLine
2\n" so the parser is explicitly tested for double-newline → new paragraph
behavior; place it near the "singleNewLines" entry so it runs with the same
suite.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5fbc8a81-4aba-4641-a6f3-58c9e1ea7c9c
⛔ Files ignored due to path filters (2)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yamltests/src/unit/core/formatConversion/parse/__snapshots__/markdown/singleNewLines.jsonis excluded by!**/__snapshots__/**
📒 Files selected for processing (3)
packages/core/package.jsonpackages/core/src/api/parsers/markdown/parseMarkdown.tstests/src/unit/core/formatConversion/parse/parseTestInstances.ts
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/mantine
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
commit: |
nperez0111
left a comment
There was a problem hiding this comment.
Ah, yea, I agree with this interpretation
Summary
Due to
text/plaincontent from the clipboard being interpreted as Markdown content, single line breaks are parsed as spaces, as Markdown typically uses a\character or 2 line breaks to indicate the start of a new paragraph.However, this is not 100% consistent across Markdown renderer implementations, and GitHub, for example, does render single new lines as actual line breaks.
Therefore, this PR adds the same behaviour, as it's currently confusing when plain text with line breaks gets pasted into editor as a single line.
Closes #2693
Rationale
#2693 proposes parsing new lines as separate paragraph blocks. In this PR, however, they get parsed as
hardBreakinline nodes.This is intentional, as imo this is a more intuitive mapping of Markdown to BlockNote content, where 1 new line -> new line in paragraph and 2 new lines -> new paragraph.
Changes
remarkBreaksplugin to Markdown parsing pipeline.Impact
N/A
Testing
Added unit testm
Screenshots/Video
N/A
Checklist
Additional Notes
N/A
Summary by CodeRabbit
Bug Fixes
Tests