Created on 29 January 2024, about 1 year ago

Problem/Motivation

I suspect i am missing something in how this works.

We have a toc type which defines header id type as number_path and header id prefix as "section". So any H2 that is missing an id, it sets the toc url anchor to something like section-1-1. Which won't work as their was no id assigned to the H2. I have written js to add H2 ids in a similar manner as to how they are defined for the toc urls.

And if it does have an id value, then it makes an anchor in the toc url like [id]-01 (ver 1.4). Which breaks the toc from working. Ver 1.3 used just [id] in the anchor, which worked correctly.

Any idea why this was changed?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ› Bug report
Status

Active

Version

1.4

Component

Code

Created by

๐Ÿ‡จ๐Ÿ‡ฆCanada liquidcms

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

Merge Requests

Comments & Activities

  • Issue created by @liquidcms
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฌ๐Ÿ‡ง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 liquidcms

    Thanks for this.. will try it out.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sumithra ramalingam

    @john_B
    #2 patch works fine. Thank you

  • ๐Ÿ‡จ๐Ÿ‡ฆ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.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 206s
    #397152
  • ๐Ÿ‡จ๐Ÿ‡ฆ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.

  • Pipeline finished with Failed
    18 days ago
    Total: 141s
    #416949
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Liam Morland Ontario, CA ๐Ÿ‡จ๐Ÿ‡ฆ

    I have rebased. Tests do not pass.

  • Pipeline finished with Failed
    18 days ago
    Total: 141s
    #416955
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia VladimirAus Brisbane, Australia

    Cheers @liam morland
    Test needs to be reverted as they were updated.

Production build 0.71.5 2024