MarkdownPlugin: serialize \n within a text child of a paragraph as line break#4835
MarkdownPlugin: serialize \n within a text child of a paragraph as line break#4835dschoorl wants to merge 2 commits intoudecode:mainfrom
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
🦋 Changeset detectedLatest commit: 7329313 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Thanks for the PR. Looks like test is failing. |
…ne break See udecode#4834 for background
ab23a04 to
bce26b0
Compare
Yes, I noticed. Those tests pass on my local machine. I am looking into it. |
…ages/code-drawing: This fixes the message when running 'yarn test': Internal Error: @platejs/code-drawing@workspace:packages/code-drawing: This package doesn't seem to be present in your lockfile; run "yarn install" to update the lockfile
JiwaniZakir
left a comment
There was a problem hiding this comment.
The handling of empty parts produced by consecutive or trailing \n characters has a subtle bug. When splitting 'text\n' (text ending with a newline), split('\n') produces ['text', ''], which causes the loop to emit [text:'text', break, break] — two break nodes instead of one — because the non-empty branch unconditionally appends a break before the empty trailing part, and then the empty-string branch appends another. A test covering a text node with a trailing \n would expose this.
The test description also has a minor mismatch: it says "two empty lines" but the input string 'Text followed by two empty lines\n\n\nFollowed by more text.' contains three \n characters, not two, and the expected output has three \\\n sequences. The test content itself is correct, but the description will mislead future readers.
Finally, the condition childParts.length !== index + 1 for "not last element" in defaultRules.ts is clearer as index < childParts.length - 1, which is the conventional idiom for this pattern in the codebase.
See #4834 for background
Checklist
yarn typecheckyarn lint:fixyarn testyarn brlyarn changeset