mixu / markdown-styles

Markdown to static HTML generator and multiple CSS themes for Markdown
1.85k stars 250 forks source link

Same titles need different id #20

Closed xcv58 closed 9 years ago

xcv58 commented 9 years ago

For example: https://maybe.xcv58.me/README.html

There're three POST as titles, they should be

<h3 id="post"><a class="header-link" href="#post"></a>POST</h3>
<h3 id="post-1"><a class="header-link" href="#post"></a>POST</h3>

and

<h3 id="post-2"><a class="header-link" href="#post"></a>POST</h3>

The same README.md in GitHub doesn't have such issue: https://github.com/xcv58/backend/blob/meteor/README.md

Could you solve this issue? If no, could you please tell me which function do the conversion of markdown to html? I can try to solve this.

Thanks!

mixu commented 9 years ago

thanks for filing this - seems like a legit bug. If you have some time to write up a PR, the rendering is done here: https://github.com/mixu/markdown-styles/blob/master/lib/pipeline.js#L13 by overriding the marked renderer, see https://github.com/chjj/marked . It's probably faster if you fix it since I tend to work on markdown-styles every couple of months or so...

mixu commented 9 years ago

boom, wrote a couple integration tests, made sure that the header text can be duplicated across files (but not in the same file) and published as v2.4.0. Sorry this took a while!

xcv58 commented 9 years ago

Cool! :+1: