Repository navigation
fix(markdown): preserve links, trailing breaks and table images - #5152
Merged
Merged
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
|
| Name | Type |
|---|---|
| platejs | Major |
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
The two www serializeMarkdown tests pinned the old trailing-break output, which read back with a lost break and a stray backslash. commonmarkSurface.slow.ts and paragraphBreaks.spec.ts already assert the round trip for the same inputs. The Chinese Markdown page now matches the English table-cell rule.
# Conflicts: # apps/www/src/__registry__/generation.json # apps/www/src/__registry__/index.tsx # apps/www/src/__registry__/overlays/manifest.json # apps/www/src/__registry__/registry-metadata.json # docs/editor-behavior/current-evidence.md
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.
Plan: Markdown regression fixes
Why
Markdown export can fail for bare URLs in headings and sized images in table cells, or lose trailing breaks in paragraphs and list items. Fix the shared conversion rules so these documents survive export and import.
Scope
commonmarkSurface.slow.tsandparagraphBreaks.spec.tsnow assert the round trip for the same inputs.Review guide
Start with
markdownIntrinsics.ts(encodeMarkdownParagraph), thenlistToMdastTree.ts, which now calls it, thenmdastContent.ts. The table-cell change is the pairmarkdownLine.ts(writer) andmarkdownTags.ts(reader). Everything underapps/www/public/randapps/www/src/__registry__is generated.Tradeoffs
Keep line-break handling in the paragraph encoder and tag handling in the existing converter. Avoid image-specific serialization and exported-string post-processing. A shorter output that writes only the last trailing break as HTML would delete the conversion loop but change every single-break snapshot, so it stays out of this fix.
Blast Radius
The shared Markdown converter is affected. No public API or editor schema changes. Tags with child content are outside the new table behavior.
Verification
c70bacbd4aand at this head: at base,a<br/><br/>reads back asa\plus one break, a list item drops its trailing break and a heading autolink throws; at this head all three round-trip.serializeMarkdownfailures were this PR's and are fixed. The other red steps fail the same way onnext(c70bacbd4aCI run 37771713058 and Plite CI run 37763729690 at592ec28578): the main-to-next sync tooling test,core-audits(rgmissing),entrypoint-graph,www(plateCLI missing) and six Plite Chromium cases (getFlatTreeParentElement is not defined). The EditorStatic reuse oracle timed out on CI and passed 3 of 3 locally in 1.4 s.Full repository checks, production builds and the browser engine matrix were not run.