Repository navigation
fix(selectors): skip id partial matching on headed level sections - #495
Open
EnesKartal wants to merge 1 commit into
Open
EnesKartal wants to merge 1 commit into
EnesKartal wants to merge 1 commit into
Conversation
This branch has not been deployed
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 #468
Root cause
isLevelSectionHeadingIdinsrc/removals/selectors.tspreviously compared<section class="levelN">IDs against a naive hyphen-normalized slug of the heading text (replace(/[^\p{L}\p{N}]+/gu, '-')). That still dropped Pandoc/Quarto content sections whoseidcontained a partial-selector word (favorite,recommend,relevant,-error) whenever:What's->whats,pass/fail->passfail), or{#custom-id}anchor for backwards-compatible URLs.Fix
In Pandoc/Quarto
--section-divsoutput,<section class="levelN">hoists the heading anchor ID onto the section wrapper. Skipidpartial matching on<section class="levelN">whenever it has asec-prefix or contains a heading (h1-h6), matching how Defuddle already skipsidon heading elements. Non-level clutter sections (e.g.#related-posts), unheadedlevelNsections, andlevelNsections with clutter class names are still removed.Verification
https://hamel.dev/blog/posts/evals-faq/: all 5 previously dropped FAQ sections are now preserved (0non-chrome partial removals).tests/table-and-section-selectors.test.ts(bothlinkedomandjsdom).npx vitest run tests/table-and-section-selectors.test.ts tests/class-selectors.test.ts: 78/78 passed.npx tsc --noEmit,npm run build:types,npm run build:node: passed.