Skip to content

fix(markdown): preserve table cells during MDX fallback#5007

Merged
zbeyens merged 3 commits into
udecode:mainfrom
kiranmagic7:fix/markdown-table-incomplete-mdx-5006
Jun 13, 2026
Merged

fix(markdown): preserve table cells during MDX fallback#5007
zbeyens merged 3 commits into
udecode:mainfrom
kiranmagic7:fix/markdown-table-incomplete-mdx-5006

Conversation

@kiranmagic7

@kiranmagic7 kiranmagic7 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor
  • Auto release

Summary

Fixes #5006.

When MDX parsing fails on plain less-than text inside a GFM table cell, the safe Markdown fallback now keeps the table structure valid instead of appending fallback inline text directly under the table node. If the incomplete MDX tail belongs to a table, the fallback replaces the partial table with the non-MDX parsed table while preserving completed blocks before it.

Testing

  • ./node_modules/.bin/bun test packages/markdown/src/lib/table.spec.ts packages/markdown/src/lib/deserializer/utils/markdownToSlateNodesSafely.spec.tsx -> 7 passed
  • PATH="$PWD/node_modules/.bin:$PATH" pnpm --filter @platejs/markdown lint -> passed
  • pnpm turbo build --filter=./packages/markdown -> 11 tasks passed
  • ./node_modules/.bin/biome check packages/markdown/src/lib/deserializer/utils/markdownToSlateNodesSafely.ts packages/markdown/src/lib/table.spec.ts .changeset/green-plants-fix.md -> passed
  • git diff --check -> passed

Notes

  • Full ./node_modules/.bin/bun test packages/markdown/src/lib reached 210 passing tests, then stopped on an existing local module-resolution issue for @platejs/list-classic/react in standardList.spec.tsx.
  • pnpm turbo typecheck --filter=./packages/markdown also fails in this checkout on existing unresolved local workspace/test imports such as @platejs/basic-nodes, @platejs/test-utils, and @platejs/table, not on this change.
  • Local codex review --base origin/main was not run because codex is not installed in this environment.

AI-assisted: yes. I understand the change and verified the focused regression locally.

@kiranmagic7
kiranmagic7 requested a review from a team June 12, 2026 09:30
@codesandbox

codesandbox Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@changeset-bot

changeset-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e08b359

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@platejs/markdown Patch

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

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. patch Bugfix & documentation PR plugin:markdown Markdown deserializer plugin:table Tables labels Jun 12, 2026
@kiranmagic7
kiranmagic7 force-pushed the fix/markdown-table-incomplete-mdx-5006 branch from cb9ae4c to bb2dbcf Compare June 12, 2026 12:37
@zbeyens

zbeyens commented Jun 12, 2026

Copy link
Copy Markdown
Member

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bb2dbcfbe3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/markdown/src/lib/deserializer/utils/markdownToSlateNodesSafely.ts Outdated
Comment thread packages/markdown/src/lib/deserializer/utils/markdownToSlateNodesSafely.ts Outdated
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jun 13, 2026
@kiranmagic7

Copy link
Copy Markdown
Contributor Author

Addressed the three markdown fallback review findings in 8de8c24:

  • Preserve blocks after the repaired fallback table instead of dropping trailing nodes.
  • Match the fallback table to the table at the MDX split point instead of selecting the last table in the full document.
  • Keep incomplete inline MDX literal text out of the previous marked text leaf.

Validation:

  • ./node_modules/.bin/bun test packages/markdown/src/lib/table.spec.ts packages/markdown/src/lib/deserializer/utils/markdownToSlateNodesSafely.spec.tsx -> 10 passed
  • PATH="$PWD/node_modules/.bin:$PATH" pnpm --filter @platejs/markdown lint -> passed, 90 files checked
  • pnpm turbo build --filter=./packages/markdown -> passed, 11 tasks
  • ./node_modules/.bin/biome check packages/markdown/src/lib/deserializer/utils/markdownToSlateNodesSafely.ts packages/markdown/src/lib/deserializer/utils/markdownToSlateNodesSafely.spec.tsx packages/markdown/src/lib/table.spec.ts .changeset/green-plants-fix.md -> passed
  • git diff --check -> passed

CI should restart on the pushed head.

@zbeyens

zbeyens commented Jun 13, 2026

Copy link
Copy Markdown
Member

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8de8c24a1f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/markdown/src/lib/deserializer/utils/markdownToSlateNodesSafely.ts Outdated
Comment thread packages/markdown/src/lib/deserializer/utils/markdownToSlateNodesSafely.ts Outdated
@kiranmagic7

Copy link
Copy Markdown
Contributor Author

Addressed the latest markdown fallback review cases in e08b359:

  • When incomplete MDX starts after an already-complete table, the parsed table is kept and the fallback tail is appended as a new paragraph instead of reparsing/replacing the table through the no-MDX path.
  • Inline fallback nodes are only concatenated into the previous text leaf when the incoming leaves are plain text too, so marked fallback leaves such as **bold** keep their marks.

Validation:

  • ./node_modules/.bin/bun test packages/markdown/src/lib/table.spec.ts packages/markdown/src/lib/deserializer/utils/markdownToSlateNodesSafely.spec.tsx -> 12 passed
  • PATH="$PWD/node_modules/.bin:$PATH" pnpm --filter @platejs/markdown lint -> passed, 90 files checked
  • pnpm turbo build --filter=./packages/markdown -> passed, 11 tasks
  • ./node_modules/.bin/biome check packages/markdown/src/lib/deserializer/utils/markdownToSlateNodesSafely.ts packages/markdown/src/lib/deserializer/utils/markdownToSlateNodesSafely.spec.tsx packages/markdown/src/lib/table.spec.ts .changeset/green-plants-fix.md -> passed
  • git diff --check -> passed

CI should restart on the pushed head.

@zbeyens
zbeyens merged commit 9012231 into udecode:main Jun 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Bugfix & documentation PR plugin:markdown Markdown deserializer plugin:table Tables size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Markdown table crashes when a table cell contains plain text with an unescaped <x character while remarkMdx is enabled.

2 participants