-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
The IDs that are automatically assigned to the headings, indirectly via the “slugify” function, are not unique.
This means that these headings cannot be accessed through the table of contents, but only the first heading with the same ID can be reached.
For example, if you have several headings with the name “Summary”, the same ID “summary” is generated for each of them.
To solve this problem, I have changed the code of the “getList” function in one place:
for ($index; $index < $headers->length; $index++) {
$curr_header = $headers[$index];
if (isset($curr_header->tagName) && $curr_header->tagName !== '') {
// Add missing id's to the h tags
$id = $curr_header->getAttribute('id');
if ($id === "") {
$id = $this->slugify($curr_header->nodeValue) . '-' . $index; // Add the index to the ID
$curr_header->setAttribute('id', $id);
}
This turns several “summary” IDs into “summary-1”, “summary-4”, “summary-n”…
Metadata
Metadata
Assignees
Labels
No labels