Skip to content

fix(selectors): preserve table rows/cells and level section heading IDs - #480

Merged
kepano merged 3 commits into
kepano:mainfrom
EnesKartal:fix/preserve-table-rows-cells-and-sections
Nov 18, 2026
Merged

kepano merged 3 commits into
kepano:mainfrom
EnesKartal:fix/preserve-table-rows-cells-and-sections

Conversation

@EnesKartal

Copy link
Copy Markdown
Contributor

Fixes #465

Summary

In src/removals/selectors.ts, exact and partial selector matching previously removed:

  1. Content table rows and cells with clutter-like class names (such as <tr class="header">, <td class="date">, <td class="timestamp">).
  2. Pandoc/Quarto <section class="levelN"> containers whose id is a sec- cross-reference label or a slug derived from the section heading (e.g., id="two-types-of-errors").

Changes

  • Added isTableCellOrRow and isInsideCodeTable guards so TR/TD/TH elements are preserved in both exact and partial selector passes unless explicitly hidden (HIDDEN_EXACT_SELECTOR) or inside a code block table (e.g., Hexo td.gutter).
  • Added isLevelSectionHeadingId so <section class="levelN"> ignores its id during partial selector matching when it starts with sec- or matches its heading's slug, while non-heading clutter sections such as #related-posts are still removed.
  • Added tests/table-and-section-selectors.test.ts covering both linkedom and jsdom.

Verification

  • npx vitest run tests/table-and-section-selectors.test.ts tests/class-selectors.test.ts: 2/2 files passed, 74/74 tests passed.
  • npx tsc --noEmit, npm run build:types, npm run build:node: passed with 0 errors.

@kepano
kepano merged commit daf6383 into kepano:main Nov 18, 2026
5 checks passed
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.

Table header rows, cells and sections removed by class/id selectors (Pandoc, Quarto, Microsoft Learn)

2 participants