Table header rows, cells and sections removed by class/id selectors (Pandoc, Quarto, Microsoft Learn)
Some selectors in EXACT_SELECTORS / PARTIAL_SELECTORS remove elements by words in their class or id, whatever the element is:
- Header rows.
.headerremoves<tr class="header">(Pandoc, Quarto, Microsoft Learn). The first data row becomes the header (the table part of #395). - Cells. A cell removed by its class (
td.date,td.timestamp, …) takes its column with it; every later value of the row shifts under the wrong heading. - Sections. Pandoc and Quarto give each
section.levelNan id from its heading (sec-taxonomy,…-with-additive-errors). The id matches a pattern and the whole section is removed (the "11.2 Two types of errors" report in #395).
Example (quarto.org/docs/authoring/tables.html), before:
| 12 | 12 | 12 | 12 |
| --- | --- | --- | --- |
| 123 | 123 | 123 | 123 |
after:
| Default | Left | Right | Center |
| --- | --- | --- | --- |
| 12 | 12 | 12 | 12 |
Fix. Following two rules selectors.ts already has (pre/code skipped, heading ids not matched):
- table rows and cells are never removed by name, except in tables holding code (Hexo's
td.gutteris still removed); - a
section.levelNid is not matched when it is its heading's slug or asec-label (section#related-postsis still removed).
Tested on 768 real pages, 0.19.6 with and without the fix: 13 change, all for the better, none for the worse; the other 755 are byte-identical. Header rows return on all 35 tables of Microsoft's exFAT spec, 16 tables of Quarto's own table guide, and tables on otexts' Forecasting (fpp2/fpp3) and gwern.net; five lost sections return on otexts and one in the Pandoc manual; values return to their columns on three pages.
Possible PR: one file, src/removals/selectors.ts, +49 / −2 lines, plus three fixtures with expected output (112 lines) that fail before and pass after. Full suite passes with linkedom and JSDOM.
Overlaps #399, which its author closed. Would you like a PR, or would you rather fix it yourself?