- Issue created by @liquidcms
- Status changed to Needs review
about 1 year ago 6:13pm 7 February 2024 - ๐ฌ๐งUnited Kingdom John_B London (UK), Worthing (UK), Innsbruck (Tirol)
If a heading text appears twice, auto-generated IDs based on the heading text must be unique, so an -01 should be added the second time that text us used to generate an ID
Also, if the markup contains an ID which is used more than once, which is of course incorrect HTML, the second copy of the ID should be modified by the module by adding -01.
There is a bug because in certain cases the -01 is being added where it is not required.
The problem is that in src/Toc.php, the line
while (isset($this->ids[$id]) || isset($this->existingIds[$id])) {
the part
isset($this->existingIds[$id]))
is returning TRUE for IDs which are not in fact duplicates. Once that is removed, the -01 is added only where there really is a duplicate ID, or a heading with duplicate text from which we risk creating a duplicate ID. A patch is attached.Note that Drupal 10 rewrote the core HTML utility, which is used to parse HTML. There are significant differences and this can create bugs. I have not checked whether the problem arose on D9.
- ๐จ๐ฆCanada Liam Morland Ontario, CA ๐จ๐ฆ
liam morland โ made their first commit to this issueโs fork.
- ๐จ๐ฆCanada Liam Morland Ontario, CA ๐จ๐ฆ
I have opened a merge request with the patch in #2.
- ๐จ๐ฆCanada Liam Morland Ontario, CA ๐จ๐ฆ
In ๐ Add testing configuration Active , tests were failing because of the bug in this issue. I put the fix from #2 in that issue and they still fail. It is a different failure related to
id
attributes not being unique. This suggest to me that the fix in #2 is not a proper fix. - ๐ฆ๐บAustralia VladimirAus Brisbane, Australia
if the currently updated tests are not correct (they were updated in dev branch), it need to be updated here.
- ๐จ๐ฆCanada Liam Morland Ontario, CA ๐จ๐ฆ
I have rebased. Tests do not pass.
- ๐ฆ๐บAustralia VladimirAus Brisbane, Australia
Cheers @liam morland
Test needs to be reverted as they were updated.