Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
leoj3n opened this issue Apr 17, 2017 · 0 comments
Open

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

leoj3n opened this issue Apr 17, 2017 · 0 comments

Comments

@leoj3n
Copy link
Contributor

leoj3n commented Apr 17, 2017

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant