fix(render): unwrap single-cell tables that wrap a nested table - #17
Open
mathurshubham wants to merge 1 commit into
Open
fix(render): unwrap single-cell tables that wrap a nested table #17mathurshubham wants to merge 1 commit into
mathurshubham wants to merge 1 commit into
Conversation
A nested table inside a cell flattens to `a / b` runs — unavoidable in GFM for real multi-cell grids, but when the outer table is a single cell it is pure layout scaffolding (the Word-form shape: one wrapper table around the actual content). Flattening there collapses the inner grid into one enormous cell for no benefit. Extend the existing trivial-layout-table unwrap in the renderer: a single-cell table whose lone cell holds a nested table now renders its content directly, letting the inner table render as a real grid. Multi-cell tables and plain 1x1 data tables are unchanged. Fixes firecrawl#14
mathurshubham
force-pushed
the
fix/unwrap-single-cell-table-wrappers
branch
from
August 6, 2026 08:41
d1041b5 to
35f278e
Compare
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.
Fixes #14.
This implements direction (3) from the issue — the narrow single-cell-wrapper
case — since it covers the reported form shape without touching genuine
nested grids or costing the clean-Markdown property.
What
A nested table inside a cell flattens to
a / bruns. For real multi-cellgrids that's unavoidable in GFM, but when the outer table is a single
cell it is pure layout scaffolding (the Word-form shape: one wrapper table
around the actual content), and flattening collapses the inner grid into one
enormous cell for no benefit.
The renderer already unwraps trivial
Layout-kind single-cell tables(
render/markdown/mod.rs); no frontend currently producesLayout, so themechanism sat unused. This PR extends that arm: a single-cell table whose
lone cell holds a nested table unwraps to its blocks regardless of kind,
letting the inner table render as a real grid.
Deliberately unchanged:
| x |1×1 data tables stay tables (existingdata_table_1x1_not_unwrappedtest still passes untouched);pins it) — that's option (1)/(2) territory and out of scope here.
Wrapper-in-wrapper unnests recursively, so multi-level form scaffolding
resolves too.
Before / after
The issue's repro (3×2 table inside a single-cell outer table), reproduced
byte-for-byte on
mainand converted with this branch:Because the fix lives in the renderer, it applies to every format that can
produce nested tables (docx, rtf, epub/html), not just docx.
Tests
shape); nested table in a multi-cell grid still flattens; wrappers unwrap
recursively; plain 1×1 data table unchanged.
handmade-nested.docx(single-cell wrapper with anested 3×2 table, plus a two-cell table with a nested table to pin the
flatten path) + its snapshot.
cargo fmt --check,clippy --workspace --all-targets --all-features -D warnings,cargo test --lockedall green; no existing snapshotchanged — the only snapshot in the diff is the new fixture's.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.