Skip to content

feat(core): backport 4 improvements to serializer from prosemirror-markdown upstream#1046

Draft
d3m1d0v wants to merge 1 commit intomainfrom
upd-serializer2
Draft

feat(core): backport 4 improvements to serializer from prosemirror-markdown upstream#1046
d3m1d0v wants to merge 1 commit intomainfrom
upd-serializer2

Conversation

@d3m1d0v
Copy link
Copy Markdown
Member

@d3m1d0v d3m1d0v commented Apr 3, 2026

Backports 4 improvements from the prosemirror-markdown upstream into the fork's MarkdownSerializerState:

  • Non-strict render fallbackserialize() with strict: false no longer throws on unknown node types; instead, block nodes render their content and leaf nodes are silently skipped
  • getMark() with strict fallback — unknown mark types throw in strict mode (default) and are silently ignored in non-strict mode, instead of causing a runtime error
  • Smarter expelEnclosingWhitespace — trailing whitespace is no longer expelled from a mark when that mark continues on the next sibling node (fixes spurious spaces between adjacent same-mark nodes)
  • atBlockStart tracking — start-of-line escape logic now uses a dedicated atBlockStart flag instead of the atBlank() || closed heuristic, making #, -, > etc. escape only at actual block start, not after inline line breaks

Tests:

  • Ported relevant test cases from prosemirror-markdown/test1.ts to Markdown.test.ts
  • Added new tests covering non-strict mode for unknown nodes and marks, expelEnclosingWhitespace with mark continuation, and atBlockStart precision for start-of-line escaping

@gravity-ui
Copy link
Copy Markdown

gravity-ui bot commented Apr 3, 2026

Storybook Deployed

@gravity-ui
Copy link
Copy Markdown

gravity-ui bot commented Apr 3, 2026

🎭 Playwright Report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant