- π¦πΊAustralia pingers
I'm going to say this use case of rendering the same heading twice isn't something I'm going to support as part of this module unless someone writes a patch.
In at least one known situation, it appears that IDs can be counted twice such that all generated IDs have '--n' appended to them. For example
<h2>Foo</h2>
<h2>Bar</h2>
<h2>Bar</h2>
<h2>Bar</h2>
should produce:
<h2 id="foo">Foo</h2>
<h2 id="bar">Bar</h2>
<h2 id="bar--1">Bar</h2>
<h2 id="bar--2">Bar</h2>
but instead produces:
<h2 id="foo--2">Foo</h2>
<h2 id="bar--4">Bar</h2>
<h2 id="bar--5">Bar</h2>
<h2 id="bar--6">Bar</h2>
One way to reproduce this issue is to install this module and configure the filter for at least one input format, then install the Metatag β module. Create a Basic page, add an H2 element, save and observe that the generated ID will end in '--2'.
The assumed reason for this is that by default, and appropriately, Metatag uses the [node:summary] token (the summary portion of the body field) for the meta description tag. If no value is provided for the body summary field, a trimmed value of the body is used as the summary and this summary contains HTML which is stripped before being inserted into the meta description but apparently not before the auto-generated IDs are created by the Auto Heading IDs filter.
I have not tracked this down precisely and I am making some assumptions so if anyone has insight, it would be welcome.
Potential solutions that did not work:
Html::resetSeenIds();
to this module's code prior to generating the IDs would work to correct this issue. Incidentally, this is being done in the module's tests. It did "work" but failed in situations where multiple fields with the same headings were added on a single page (with heading numbering resetting on each usage of the input format on a page). Closed: won't fix
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
I'm going to say this use case of rendering the same heading twice isn't something I'm going to support as part of this module unless someone writes a patch.