BUG Skip headings function
-
I’d like to report a bug in the “Skip headings” feature (Misc settings).
The skip logic in
plugin/contentHandling/ContentHandling.phpruns after the heading has already been added to$result->headings[]. This means the heading still appears in the table of contents — only the anchor span in the content is skipped.Relevant code (around line 56–66):
$result->headings[] = [ 'id' => $id, 'index' => $index, 'label' => $label, ]; if (!$dto->modify || in_array('h' . $index, $dto->skipLevels) || ($skipRegex && preg_match($skipRegex, $label)) ) { continue; }The
continueskips inserting the anchor<span>into the content, but the heading has already been pushed to the result array. So the TOC entry is still rendered, but without a working anchor link — which is worse than not skipping at all.Expected behavior: A heading matched by the skip pattern should be excluded from the TOC, but its anchor ID should still be inserted into the content (for external links pointing to that heading).
The fix would be to separate the two concerns:
- Always insert the anchor span (or at least when
$dto->modifyis true) - Only add the heading to
$result->headings[]if it does not match the skip pattern
Thank you for looking into this!
- Always insert the anchor span (or at least when
You must be logged in to reply to this topic.