fix: stop serializer inserting trailing-backslash hard breaks and stripping blank lines on save#806
Open
mvanhorn wants to merge 26 commits into
Open
fix: stop serializer inserting trailing-backslash hard breaks and stripping blank lines on save#806mvanhorn wants to merge 26 commits into
mvanhorn wants to merge 26 commits into
Conversation
Strip BlockNote's lone trailing-backslash soft-break artifact in compactMarkdown so ordinary paragraph-internal newlines stay soft breaks, while preserving authored double-backslash hard breaks and leaving fenced and indented code blocks untouched. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
The Frontend Tests & Quality Checks failure reproduces on main's own CI (latest main run fails the same workflow), so it isn't introduced by this PR's serializer change. |
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.
Summary
Stops the rich-editor markdown serializer from rewriting users' source on every autosave by stripping BlockNote's lone trailing-backslash soft-break artifact in
compactMarkdown.blocksToMarkdownLossyemits a CommonMark hard break (a single trailing\) for every paragraph-internal line break, even ordinary soft breaks the user typed.compactMarkdownis already the post-processor for BlockNote output, so the cleanup lives there: a lone trailing\is removed (restoring a plain soft break) while an authored double-backslash\\hard break is preserved untouched. Fenced code blocks (existinginCodeBlockguard) and indented code blocks (new guard) are left unchanged.Why this matters
Issue #798: when a note is edited, the serializer inserts trailing
\hard breaks on single newlines inside a paragraph. For users who also edit notes outside Tolaria or paste prose from external sources, every autosave mutates the file on disk even when no semantic change was made, churning their source markdown.Testing
pnpm exec vitest run src/utils/compact-markdown.test.ts— 35 passed (5 new: soft-break stripping, inline-closer soft breaks, authored double-backslash preservation, indented-code-block preservation, idempotency).pnpm exec eslint src/utils/compact-markdown.ts src/utils/compact-markdown.test.ts— clean.pnpm exec tsc --noEmit— clean.src/utils/suite green except one pre-existing, unrelated failure inreleaseDownloadPage.test.ts(Windows authenticode workflow YAML), which also fails on the unmodified base.New behavior covered:
\.\\hard break is preserved.Fixes #798
AI was used for assistance.