firecrawl / firecrawl/anydoc

Nested tables are flattened into a single cell, losing the inner grid

Open
#14 1 comment 0 reactions 0 assignees View on GitHub
bug needs-design P2
Dominant language
Rust
Stars
21.5k
Forks
1.3k
Avg merge
42m
Merged PRs (30d)
17

Description

Converting a `.docx` whose tables nest (a `` inside a ``) preserves all the text but collapses the inner table's structure into a single parent cell, with ` / ` between cells and `
` between rows.

This is clearly deliberate — `render/markdown/table.rs:131-145` flattens `Block::Table` inside a cell, and the comment notes empty cells are kept so values stay in their source column positions. GFM tables genuinely cannot nest, so there's no pure-Markdown answer. Filing it because nested tables are very common in real-world Word *forms*, where the whole document body is often one outer table wrapping the real content, and the result is a single enormous line.

### Repro

Minimal `.docx` with one 3x2 table inside a single-cell outer table:

```
Before

| |
| --- |
| Section A
Metric / Value
Height / 120
Weight / 34
End of section |

After
```

The inner table's rows and columns are no longer recoverable — `Height / 120` reads as one string, and a consumer can't tell the ` / ` from a literal slash in the source text.

### Why it matters

On a real form-style document (an outer table wrapping several nested tables, ~1,800 words), this produced one table cell of **11,588 characters** on a single line. Text recall was ~100%, so nothing was lost — but the tabular structure that carried the meaning was, and the output is hard for a downstream consumer to use.

### Possible directions

1. **HTML `` fallback for nested tables only.** GFM passes raw HTML through, and the renderer already emits `
`, so HTML is not a new concept in the output. Costs the clean-Markdown property for these cells.
2. **Unnest**: emit the inner table as a sibling block after the outer one, leaving a short placeholder in the cell. Loses containment, keeps the grid.
3. **Unwrap single-cell outer tables.** Narrower and cheap: a 1x1 table whose only cell holds block content is pure layout, so rendering its contents directly as blocks would fix the common form case without touching genuine nested grids.

(3) alone would cover most of what I hit. Happy to send a PR if one of these is the direction you'd want.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in render/markdown/table.rs:131-145, where Block::Table content inside a cell is flattened, and reproduce the behavior with the minimal nested-table .docx described here. Confirm the chosen direction with the maintainer, then ensure nested table structure remains usable without confusing separators and add coverage for the reported 3x2-in-1x1 case.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.