Repository navigation
fix(markdown): split code_block lines on CRLF and CR - #5328
Merged
zbeyens merged 3 commits intoNov 4, 2026
Merged
Conversation
mdast keeps the original line endings in a fenced code value, so splitting on \n alone left a trailing \r on every code_line but the last and serialization wrote mixed line endings inside the fence. Split on \r\n, \r or \n so CRLF input produces the same value as its LF version. Fixes udecode#5322
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
🦋 Changeset detectedLatest commit: 96791d9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Move the fix from the code block rule to `markdownToSlateNodes`, so paragraphs, quotes, list items, inline code and math lose the carriage return too. The test now checks that each line ending parses to the value of its LF version. Refs plate#5322 and plate#5323
Member
On top of the PR
Verification
|
This was referenced Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5322
Problem
For a fenced code block with CRLF line endings,
deserializeMdkept a trailing\ron everycode_lineexcept the last, andserializeMdthen wrote CRLF inside an LF fence.Fix
The
code_blockdeserialize rule splitmdastNode.valueon\nonly. It now splits on\r\n,\ror\n, so CRLF/CR input gives the same value and serialized output as its LF version. LF input is unchanged.Tests
Added
codeBlockLineEndings.spec.tscovering CRLF and CR input: value equals the LF value, no\rin the value, serialize output equals the LF output. Patch changeset for@platejs/markdownincluded.Verification
I have not run the spec or
pnpm checklocally (full monorepo checkout wasn't possible in my environment); relying on CI. The split pattern was checked in plain Node.