medfreeman / markdown-it-toc-and-anchor

markdown-it plugin to add a toc and anchor links in headings
MIT License
60 stars 35 forks source link

resetIds doesn't work #8

Closed tylerlong closed 8 years ago

tylerlong commented 8 years ago

How to reproduce:

var markdownIt = require("markdown-it");
var markdownItTocAndAnchor = require("markdown-it-toc-and-anchor").default;

var mdi = markdownIt({ html: true, linkify: true, typography: true,}).use(markdownItTocAndAnchor, { resetIds: true });
mdi.render('# heading');
mdi.render('# heading');
mdi.render('# heading');
> var markdownIt = require("markdown-it");
undefined
> var markdownItTocAndAnchor = require("markdown-it-toc-and-anchor").default;
undefined
> 
> var mdi = markdownIt({ html: true, linkify: true, typography: true,}).use(markdownItTocAndAnchor, { resetIds: true });
undefined
> mdi.render('# heading')
'<h1 id="heading"><a class="markdownIt-Anchor" href="#heading">#</a> heading</h1>\n'
> mdi.render('# heading')
'<h1 id="heading-2"><a class="markdownIt-Anchor" href="#heading-2">#</a> heading</h1>\n'
> mdi.render('# heading')
'<h1 id="heading-3"><a class="markdownIt-Anchor" href="#heading-3">#</a> heading</h1>\n'
MoOx commented 8 years ago

That looks like a bug. PR welcome :)

medfreeman commented 8 years ago

I've made the necessary changes here : https://github.com/medfreeman/markdown-it-toc-and-anchor/tree/wip I'll make a pull request after the other changes are integrated.

MoOx commented 8 years ago

feel free to push another PR ;)