angular/dgeni-packages

Markdown headings with ` are generating inconsistent ids

Narretz opened this issue · 3 comments

When a heading has a `, it will be replaced by -, which makes sense, but also makes it difficult to link to these sections, because you don't expect that.

Example:

# ngOptions`` generates <h1 id="-ngoptions-">...</h1>

Do you suggest that we strip off quotes from the front and back before applying dash-case?

I suppose this could become a PR for https://github.com/blakeembrey/sentence-case/blob/master/sentence-case.js which is the used implementation. (Adding an option to strip leading/trailing replacement characters, or even by default)

Er, scratch that. sentence-case actually does this correctly. This particular case is using the implementation from https://github.com/chjj/marked/blob/3c191144939107c45a7fa11ab6cb88be6694a1ba/lib/marked.js#L788. There's an old PR for it: markedjs/marked#456

It looks like marked is no longer being maintained.
We should look to migrate to using https://github.com/markdown-it/markdown-it
with the https://www.npmjs.com/package/markdown-it-anchor plugin