Header ID type 'key' produces incorrect anchor links

Created on 27 November 2023, about 1 year ago

Problem/Motivation

When the TOC header ID type is set to 'key' and the TOC filter option 'Exclude text above the TOC' is checked, the anchor links in the TOC will be incorrect.

Steps to reproduce

- Set the Simple TOC type to use 'key' header ID types.
- In the configuration of the text input format, activate the TOC filter and set the filter to use the Simple TOC type. Leave the "automatically include TOC" option blank, don't check the "display contents in a block", but check the "Exclude text above the TOC" option.
- Create a page. Use the text input that has the TOC filter enabled. Create several H2 headings in the page, but place the TOC element below the first heading, above the second heading.
- When the page is published, view the source of the page. The anchor link keys in the TOC will begin with the number 1 even though the key number 1 has been assigned to the first heading (which is ignored by the TOC filter).

Proposed resolution

Either the ignored heading should not receive an id attribute with a key value or the anchor links in the TOC should begin with the key value of the first heading that is actually used in the contents, rather than 1.

πŸ› Bug report
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States aaronpinero

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024