fix(mdxish): parse <Table> as single token to prevent blank-line fragmentations#1371
Conversation
…rm-15613-properly-parse-and-render-fragmented-table-elements
|
okay im trying something new in this commit 753a8e4 i realised now that the tokenizer can ensure the entire |
|
with the new tokenizer, the entire
EDIT (some follow ups):
|
There was a problem hiding this comment.
This is working well, save for a couple issues I noticed:
- an unclosed
<Table>component will swallow all following content1 - writing “</Table>” in an inline code snippet inside a cell is not auto-escaped1
The second one is really more of an edge case, but the first one I think we actually need to fix before this gets merged?
Footnotes
| * | ||
| * @see https://github.com/syntax-tree/mdast#flowcontent | ||
| */ | ||
| export const FLOW_TYPES = new Set([ |
There was a problem hiding this comment.
exposing a list of FLOW_TYPES here for consumers to use, I was deliberating to make a new Set over in the monorepo but opted to just put this as an import so we can a single SOT
There was a problem hiding this comment.
This is to help with differentiating when to use GFM vs JSX table syntax in the editor serialization right?
There was a problem hiding this comment.
yea, tldr, if the table contains any FLOW types (except html) then we serialize to JSX syntax to keep it rich (ie to allow code blocks)
| expect(cells).toHaveLength(2); | ||
| }); | ||
|
|
||
| it('does not swallow content after an unclosed Table', () => { |
There was a problem hiding this comment.
Do we also need to check there's no table nodes in the tree?
This PR was released!🚀 Changes included in v13.6.1 |


🧰 Changes
CommonMark's HTML block type 6 (spec) matches
<Table>case-insensitively against the table tag, which means it terminates at blank lines. Since<Table>JSX blocks always have blank lines between rows and sections, the mdxish pipeline was fragmenting them into multiple broken nodes.Adds a custom micromark tokenizer (
jsxTable) that grabs<Table>before the built-inhtmlFlowparser and consumes everything through</Table>as a single tokenmdast-util-from-markdownextension turns that token into anhtmlnodemdxishTablestransformer handles the rest by re-parsing it withremarkMdxinto proper table nodesDemo
Screen.Recording.2026-03-16.at.19.30.56.mov
Warning
There still needs some work to be done on the monorepo side to fully support editing fragmented tables but for the moment, this PR ensures that we are rendering fragmented tables correctly. ie if you go back and forth in raw and rich mode in the new editor it breaks
This PR is essentially part 1 of solving RM-15601 and RM-15600
🧬 QA & Testing
Paste this in the demo app, it should render as ONE big table
and some edge case tests if you are interested