Skip to content

Make generated anchors less brittle so they can be externally linked #1

Description

@dchambers

If an anchor isn't explicitly supplied then one is generated, but based on the headings' current position within the document, rather than the name of the heading. I've worked around this issue locally by replacing:

anchorId = config.anchorPrefix + tocLevel + '-' + tocSection;

with:

anchorId = encodeURIComponent(config.anchorPrefix + el.text().toLowerCase().replace(/ /g, '-'));

but obviously any proper solution would need to handle the case where the same heading name had been used multiple times (e.g. for a sub-heading), in which case the positional information could be included again to disambiguate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions