Repository navigation
fix(documents): HTML table fixes (#1847, #1477) - #1904
Merged
Merged
Conversation
Workiva-generated filings place empty <td colspan="3" style="display:none"/> cells in body rows. Browsers give them no grid slot, but TableProcessor counted their colspan, so body rows were wider than the header and values after a spacer slid right under the next period. JPM FY2024 10-K (0000019617-25-000270): the 2023 managed-basis overhead ratio 54% exported under 2022. _process_row now skips a td/th whose inline style is display:none and whose text is empty. visibility:hidden and hidden cells with text are kept. A row made only of hidden spacers keeps them, since emptying it drops the row and shifts the matrix's leading-row heuristics (that variant lost % columns in 17 dataframes). Blast radius over tests/fixtures/html (85 files, 12,948 tables): no header text or header row count changes; markdown body cells identical in every table; 220 tables get a different markdown header line (the label each column carries), sampled and all corrections, e.g. JNJ 10-K 2024 values moved from 2023 to 2024 and JPM CCB 2022 revenue moved from the CIB 2022 column to CCB 2022. Fixes #1847 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The SEC XBRL viewer (R1.htm, R2.htm, ...) renders header rows with th cells
and every fact row with a td class="pl" label cell. The generic header
heuristics read Apple's cover-page facts ("Document Type | 10-Q",
"Document Quarterly Report | true", "Document Period End Date | Mar. 29,
2025") as period headers and moved them into table.headers, dropping them
from the body and Markdown. Apple 10-Q 0000320193-25-000057, R1.htm.
A row whose first own cell is td.pl AND that carries a value in another
cell now skips header detection entirely (including the year/unit
continuation checks). Label-only abstract rows ("[Line Items]",
"[Roll Forward]") are left to the generic heuristics: a first version that
moved them too changed 10 R reports and the row counts of Apple's equity
statement (R6) that five existing tests pin. The check sits on the
"if not data_rows_started" line, outside the hunks of open PR #1556.
Blast radius: tests/fixtures/html contains no class="pl" cells, so none of
its 12,948 tables can change. Over the 42 Apple R reports (381 tables),
only R1 changes, and only by the three facts above. The R1 entry of
tests/fixtures/filing_summary/report_render_baseline.json is re-captured:
it had pinned the bug (header date "Apr. 18, 2025" printed on the
Document Period End Date row, header rule below the facts).
Fixes #1477
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dgunning
marked this pull request as ready for review
November 11, 2026 01:23
dgunning
added a commit
that referenced
this pull request
Nov 11, 2026
PR #1904 (GH #1847) skips hidden display:none spacer cells, which correctly aligns the "Twelve Months Ended" header over the "$" column in CAT's ME&T free cash flow table. That exposes a latent fast_table currency-merge bug (header rows vote in _should_merge_columns), so the 2024 value renders "$ 11,437" instead of "$11,437": +4 chars, 104421 -> 104425. Values are unchanged. A body-rows-only voting fix restores 104421 but changes text() in 1,590 fixture tables and all 9 length pins, so it is tracked separately in bead edgartools-k7mi8.4. Refs #1847 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 14, 2026
dgunning
added a commit
that referenced
this pull request
Nov 20, 2026
…2014) #1903 made _project_escaped drop ix:exclude and unwrap ix: elements at every depth of an escaped TextBlock child (GH #1770). It found them by testing every descendant from Python, three times per child: once to decide whether to copy, then twice over the copy. Nested TextBlocks put the same subtrees through that hundreds of times per filing. On Apple's FY2026 10-K (0000320193-26-000026) the step took 17.9 ms per parse, and full parsing slowed about 8% between 6.0.0 and 6.1.0. The ix: tag names a document uses are now collected once per tree, and tag-filtered iterdescendants(), strip_elements() and strip_tags() do the detection and removal in libxml2. _is_xbrl_element and the new path share one predicate, _is_ix_tag. Measured on that filing (min of 7, interleaved): _project_escaped 17.9 -> 8.3 ms, parse 0.384 -> 0.376 s, median 0.400 -> 0.390 s. The remaining regression is the deep copy and serialization the correct output needs (8.4 ms) and the HTML table changes in #1904. Equivalence: projection output identical to the previous implementation on all 14,836 escaped-TextBlock children in the 86 inline fixtures (4,632 of them changed by projection); all 247,860 extracted facts byte-identical. A new test pins the per-tree tag cache and fails when the cache ignores the tree. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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
Two HTML table fixes in
edgar/documents/strategies/table_processing.py, one commit each.#1847: hidden spacer cells put JPM overhead ratios under the wrong year
Cause. Workiva output puts empty
<td colspan="3" style="display:none"/>cells inside body rows. Browsers give them no grid slot, butTableProcessor._process_rowcounted their colspan. Body rows ended up 45 columns wide under a 36-column year header, so values after the first spacer slid right under the next period.Fix.
_process_rowskips atd/thwhose inline style isdisplay:noneand whose text is empty.visibility:hiddencells and hidden cells that hold text are kept. A row made only of hidden spacers keeps them: emptying such a row drops it, which shifts the matrix's leading-row heuristics. A first version without this guard lost%columns in 17 dataframes.#1477: Apple cover-page facts moved into column headers
Cause. The SEC XBRL viewer (R1.htm, R2.htm, ...) renders header rows with
thand each fact row with atd class="pl"label cell. The generic header heuristics read "Document Period End Date | Mar. 29, 2025" as a period header.Fix. A row whose first own cell is
td.pland that carries a value in another cell skips header detection, including the year/unit continuation checks. Label-only abstract rows ([Line Items],[Roll Forward]) are left as they were. A first version that moved them too changed 10 R reports and the Apple equity-statement (R6) row counts that five existing tests pin. The change is on theif not data_rows_startedline, outside the hunks of open PR #1556 (git merge-treewith #1556's head merges cleanly).Not included
detected_scale/_detect_table_scale, which fix(earnings): preserve footnoted EPS and reported table currencies #1864 rewrites. fix(earnings): preserve footnoted EPS and reported table currencies #1864 does not change Snail either, so it should follow fix(earnings): preserve footnoted EPS and reported table currencies #1864.Verification
Ground truth
tests/fixtures/html/jpm/10k/jpm-10-k-2025-02-14.html), reported-to-managed reconciliation, "Overhead ratio" row read from the raw HTML: Reported 52/55/59 and Managed basis 51/54/58 for 2024/2023/2022. On main,to_dataframe()gives 54 and 58 both under (2022, Managed basis). With this change all six land under their own year.R1.htm(tracked fixture): "Document Type | 10-Q", "Document Quarterly Report | true" and "Document Period End Date | Mar. 29, 2025" are now body rows.Regression tests.
tests/issues/regression/test_issue_1847.py(7 tests) andtests/issues/regression/test_issue_1477.py(3 tests). Each fails on the code before its commit: 2 failures in each file. Both include silence/negative controls: visibility:hidden kept, hidden text kept, all-hidden row kept, and an ordinarytdperiod row still detected as a header.Table blast radius, #1847 (main vs branch, every table in
tests/fixtures/html: 85 files, 12,948 tables)to_dataframe(): values move to a different header in 43 headered tables, and 46 tables gain values that main dropped. Examples: BAC residential-mortgage table, where main dropped the whole "Dec 31 2023 outstandings" column; JPM 10-Q level-3 roll-forward, where main left most columns empty. 17 tables "lose" values, all checked. Most are$merged into the amount ($1,340vs$+1340.0). The rest: a duplicated header label removed (FCX), footnote(a)markers that the dataframe consolidator drops but Markdown keeps (JPM), and misplaced values replaced by correct ones (JPM 10-Q).Table blast radius, #1477.
tests/fixtures/htmlcontains noclass="pl"cells, so 0 of its 12,948 tables can change. Over the 42 Apple R reports (381 tables), only R1 changes, and only by the three facts.Golden updates (please review)
tests/fixtures/filing_summary/report_render_baseline.json: the R1 entry is re-captured (HTML table parser moves Apple cover-page values into column headers #1477 commit). It had pinned the bug: the header date "Apr. 18, 2025" printed on the "Document Period End Date" row, and the header rule sat below the facts. Same words; the date moves to the header line and the rule moves above "Document Type". A comment next to the existing R8/R13/R14 re-capture note explains it.tests/issues/regression/test_dt1f1_10q_part_boundary.py: GS 10-Qpart_i_item_1length re-pinned 627,581 → 627,501, in two places ([DATA] Inline display:none spacer cells assign JPM overhead ratios to wrong years #1847 commit). Checked the way the earlier moves of that pin were: the 68,281 words are identical and in the same order, the first and last 80 characters are byte-identical, and the other seven sections are unchanged. The only diff is one market-making revenue table losing a dead padding column.Suite.
hatch run test-fast: 50,759 passed, 9 skipped, 1 xfailed, 0 failed (hatch run test-fast, 11m53s). Ruff is clean on the changed files. Changed/added functions are under complexity 15;_process_table_structureand_is_header_rowwere already over 15 on main and are untouched apart from one condition.Fixes #1847
Fixes #1477
AI tool/model: Claude Code, Claude Opus 5.5
🤖 Generated with Claude Code