Fix: table cells serialize empty in JSON output#45
Open
sh3raawii wants to merge 1 commit into
Open
Conversation
table_cell_to_legacy builds a cell's kids from cell.contents (semantic ContentElements), and elements_to_legacy skips raw TextChunks. But the border-detection content-assignment path stores cell text in the other field, cell.content (TableTokens). So border-detected tables serialize every cell as "kids": [] in JSON, dropping all cell text — while the Markdown/HTML/text outputs (which read cell.content) render fine. When contents yields no kids, fall back to the cell's content tokens and synthesize a paragraph kid from their text, mirroring the fallback the same file already uses for list items.
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.
Summary
Border-detected table cells serialize with empty
kidsin JSON output, droppingall cell text — even though the same tables render correctly in Markdown, HTML,
and text.
Root cause
table_cell_to_legacybuilds a cell'skidsfromcell.contents(
Vec<ContentElement>), andelements_to_legacyintentionally skips rawTextChunk/TextLine/TextBlockelements. But the border-detectioncontent-assignment path (
table_content_assigner::assign_to_cell) stores acell's text in the other field,
cell.content(Vec<TableToken>):So for any table populated by the border detector,
cell.contentsis empty andthe token text in
cell.contentis never emitted → every cell comes out as"kids": []. Markdown/HTML/text readcell.content, so they are unaffected;only JSON loses the data.
Fix
In
table_cell_to_legacy, whencontentsyields no kids, fall back to thecell's
contenttokens and synthesize aparagraphkid from their text. Thismirrors the fallback the same file already uses for list items ("First tries
semantic contents (preferred), then falls back to raw body tokens").
Before / after
A born-digital 6×2 key-value table (
Input | Value,Equity volatility | 55%,…) that Markdown renders in full previously produced 12 empty cells in JSON.
After the fix, each cell's
kidscontains a paragraph node with the cell text.Changes
crates/edgeparse-core/src/output/legacy_json.rs—table_cell_tokens_to_paragraphhelper and a fallback in
table_cell_to_legacy.