markdown-toc icon indicating copy to clipboard operation
markdown-toc copied to clipboard

Invalid hashes for headers that differ only in not alphanumeric characters

Open vsemozhetbyt opened this issue 6 years ago • 1 comments

See https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md with TOC autogenarated by the markdown-toc.

Compare the links for:

page.$(selector) page.$$(selector)

page.$$eval(selector, pageFunction[, ...args]) page.$eval(selector, pageFunction[, ...args])

frame.$(selector) frame.$$(selector)

frame.$$eval(selector, pageFunction[, ...args]) frame.$eval(selector, pageFunction[, ...args])

elementHandle.$(selector) elementHandle.$$(selector)

GitHub generates the second id for such pairs by adding -1 to it.

vsemozhetbyt avatar Oct 27 '17 17:10 vsemozhetbyt

Thanks for the issue!

I think I see how this can be fixed. We need to either get the title ('getTitle') or slugify without the num option first, then check to see if the result matches another header that we've already seen. Then slugify again with the num option set.

I'll try to get a PR together tonight unless someone else gets to it first.

doowb avatar Oct 27 '17 18:10 doowb