• I’d like to report a bug in the “Skip headings” feature (Misc settings).

    The skip logic in plugin/contentHandling/ContentHandling.php runs 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 continue skips 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:

    1. Always insert the anchor span (or at least when $dto->modify is true)
    2. Only add the heading to $result->headings[] if it does not match the skip pattern

    Thank you for looking into this!

You must be logged in to reply to this topic.