Skip to content

This plugin should add IDs to header elements (if missing) #23

@leoj3n

Description

@leoj3n
Contributor

Seem like this code:

https://github.com/canjs/bit-docs-html-canjs/blob/d1352069818e053453a5f082fad68e08f79f3ad6/static/canjs.js#L187-L210

Should be part of this plugin, especially considering the regex for building the ID could change here but not there, thus breaking the anchor links:

function makeHeadingId(text) {
return (text || "")
.replace(/\s/g, "-") // replace spaces with dashes
.replace(/[^\w\-]/g, "") // remove punctuation
.toLowerCase();
}

Also, it's something needed for any bit-docs website that wants to include this plugin, so why not implement here rather than re-implement it in every bit-docs website?

Adding of IDs could be toggled on/off with a setting if needed, and it could be smart enough to use any existing IDs on the header elements, or smart enough to enumerate for headings with the same contents on the same page (thus otherwise having identically generated IDs).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @leoj3n

        Issue actions

          This plugin should add IDs to header elements (if missing) · Issue #23 · bit-docs/bit-docs-html-toc