fix(mdxish): don't serialise GFM tables -> JSX because of line breaks - #1577
Conversation
|
@CodeRabbit review |
✅ Action performedReview finished.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe change adds reusable GFM table-cell normalization helpers and separates cell classification from table conversion. GFM-safe cells convert breaks and embedded newlines to Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
__tests__/lib/mdxish/mdxishMdastToMd.test.tsOops! Something went wrong! :( ESLint: 8.57.1 Error: Error while loading rule ' __tests__/transformers/mdxish-tables-to-jsx.test.tsOops! Something went wrong! :( ESLint: 8.57.1 Error: Error while loading rule ' Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
processor/transform/mdxish/tables/mdxish-tables-to-jsx.ts (1)
85-100: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRename the JSX-promotion flag.
canCellBeGfmalso rejects newlines ininlineCodeand rawhtml. In those cases,hasFlowContentis true even though the cell has no flow child. Rename it torequiresJsxTable.As per coding guidelines: name code according to its behavior.
Proposed refactor
- let hasFlowContent = false; + let requiresJsxTable = false; ... - hasFlowContent = true; + requiresJsxTable = true; ... - if (!hasFlowContent) { + if (!requiresJsxTable) {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@processor/transform/mdxish/tables/mdxish-tables-to-jsx.ts` around lines 85 - 100, Rename the hasFlowContent flag to requiresJsxTable throughout the table transformation logic, including its declaration and assignments, so the name reflects that the condition determines whether JSX promotion is required rather than whether flow content exists. Preserve the existing canCellBeGfm check and branching behavior.Source: Coding guidelines
__tests__/transformers/mdxish-tables-to-jsx.test.ts (1)
100-188: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd direct recursion coverage.
The current cases verify direct cell children. They do not exercise recursive
normalizeNodesbehavior. Add a focusednormalizeCellForGfmAST test for breaks inside nestedemphasisandstrong, anescapenode, and leading, trailing, and consecutive newlines. Keep the existing serialization tests.Based on learnings:
mdxishTablesruns only in the MDXish pipeline, so equivalent RMDX coverage is not applicable. As per coding guidelines: unit-test dense logic directly and cover emphasis variants, escapes, nesting, whitespace, and formatting differences.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@__tests__/transformers/mdxish-tables-to-jsx.test.ts` around lines 100 - 188, Add focused unit coverage for normalizeCellForGfm that directly passes AST nodes containing breaks nested within emphasis and strong, including escape nodes and leading, trailing, and consecutive newline cases. Assert the normalized recursive AST preserves the expected formatting and whitespace behavior, while retaining the existing round-trip serialization tests unchanged.Sources: Coding guidelines, Learnings
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@processor/transform/mdxish/tables/gfm-cell-normalization.ts`:
- Around line 26-30: Update isBareListMarker to accept only a single empty list
item whose checked state is null, preserving task-list state and multiple-item
counts through the existing JSX path. Add CX-3773 regression coverage in the
transformer and MDXish serializer suites for unchecked/checked task items and
multi-item empty lists, including the cited ticket.
---
Nitpick comments:
In `@__tests__/transformers/mdxish-tables-to-jsx.test.ts`:
- Around line 100-188: Add focused unit coverage for normalizeCellForGfm that
directly passes AST nodes containing breaks nested within emphasis and strong,
including escape nodes and leading, trailing, and consecutive newline cases.
Assert the normalized recursive AST preserves the expected formatting and
whitespace behavior, while retaining the existing round-trip serialization tests
unchanged.
In `@processor/transform/mdxish/tables/mdxish-tables-to-jsx.ts`:
- Around line 85-100: Rename the hasFlowContent flag to requiresJsxTable
throughout the table transformation logic, including its declaration and
assignments, so the name reflects that the condition determines whether JSX
promotion is required rather than whether flow content exists. Preserve the
existing canCellBeGfm check and branching behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2108cc21-e317-499b-9152-3fd7e33e6b4f
📒 Files selected for processing (4)
__tests__/lib/mdxish/mdxishMdastToMd.test.ts__tests__/transformers/mdxish-tables-to-jsx.test.tsprocessor/transform/mdxish/tables/gfm-cell-normalization.tsprocessor/transform/mdxish/tables/mdxish-tables-to-jsx.ts
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
readmeio/ai(manual)readmeio/gitto(manual)readmeio/markdown(manual)readmeio/readme(manual)
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@__tests__/lib/mdxish/mdxishMdastToMd.test.ts`:
- Around line 1118-1141: Strengthen the tests around mdxishMdastToMd by
asserting serialized JSX content rather than only checking for <Table>. Verify
that the empty task item preserves its checked state, add a checked: true case,
and assert that the multiple-empty-item case retains both items. Include a
CX-3773 regression reference in the test descriptions or nearby test
documentation.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 12d6e845-6b8a-4121-839c-bab063f24d7e
📒 Files selected for processing (4)
__tests__/lib/mdxish/mdxishMdastToMd.test.ts__tests__/transformers/mdxish-tables-to-jsx.test.tsprocessor/transform/mdxish/tables/gfm-cell-normalization.tsprocessor/transform/mdxish/tables/mdxish-tables-to-jsx.ts
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
readmeio/ai(manual)readmeio/gitto(manual)readmeio/markdown(manual)readmeio/readme(manual)
🚧 Files skipped from review as they are similar to previous changes (2)
- tests/transformers/mdxish-tables-to-jsx.test.ts
- processor/transform/mdxish/tables/mdxish-tables-to-jsx.ts
This PR was released!🚀 Changes included in v14.14.2 |

🎯 What does this PR do?
<Table>on save (customer request)breaknodes and newlines inside text become<br />🧪 QA tips
Link this branch into the app locally (
npm run build && npm linkhere, thennpm link @readme/markdownin the app repo) and test in the mdxish editor:Start from a plain pipe table, press shift+enter (or paste multi-line text) inside a cell, save → the doc should stay a pipe table with
<br />in the cell, not turn into<Table>:Re-save the doc a couple of times → output is stable, no drift back to
<Table>.Sanity-check that real flow content in a cell still converts to
<Table>on save: use the editor UI to insert a bulleted list (with text in the items), multiple paragraphs, or a code block inside a cell → the saved doc should contain<Table>, e.g.:📸 Screenshot or Loom
Before vs After:
Screen.Recording.2026-08-04.at.9.39.03.pm.mov