Skip to content

Fix: table cells serialize empty in JSON output#45

Open
sh3raawii wants to merge 1 commit into
raphaelmansuy:mainfrom
sh3raawii:fix/json-table-cell-content
Open

Fix: table cells serialize empty in JSON output#45
sh3raawii wants to merge 1 commit into
raphaelmansuy:mainfrom
sh3raawii:fix/json-table-cell-content

Conversation

@sh3raawii

Copy link
Copy Markdown

Summary

Border-detected table cells serialize with empty kids in JSON output, dropping
all cell text — even though the same tables render correctly in Markdown, HTML,
and text.

Root cause

table_cell_to_legacy builds a cell's kids from cell.contents
(Vec<ContentElement>), and elements_to_legacy intentionally skips raw
TextChunk / TextLine / TextBlock elements. But the border-detection
content-assignment path (table_content_assigner::assign_to_cell) stores a
cell's text in the other field, cell.content (Vec<TableToken>):

ContentElement::TextChunk(tc) => {
    cell.content.push(TableToken { base: tc.clone(), token_type: TableTokenType::Text });
}

So for any table populated by the border detector, cell.contents is empty and
the token text in cell.content is never emitted → every cell comes out as
"kids": []. Markdown/HTML/text read cell.content, so they are unaffected;
only JSON loses the data.

Fix

In table_cell_to_legacy, when contents yields no kids, fall back to the
cell's content tokens and synthesize a paragraph kid from their text. This
mirrors 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 kids contains a paragraph node with the cell text.

Changes

  • crates/edgeparse-core/src/output/legacy_json.rstable_cell_tokens_to_paragraph
    helper and a fallback in table_cell_to_legacy.

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.
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