nagaozen / markdown-it-toc-done-right

A table of contents (TOC) plugin for Markdown-it with focus on semantic and security. Made to work gracefully with markdown-it-anchor.
MIT License
133 stars 26 forks source link

Add option to set slugStartIndex #41

Closed ErikMichelson closed 3 years ago

ErikMichelson commented 3 years ago

Note: This PR is based on #39, which should be merged prior to this one. (done)

This PR adds the option slugStartIndex that allows to define a custom number to start the counting of suffixes for duplicate headings.

If #40 is merged before this, I will add the change in types of course with this PR too. (done)

Breaking: This PR sets the default value for slugStartIndex to 1 to be compatible with markdown-it-anchor v6 out of the box.

Example:

# heading
# heading

will now result in something like this (note the suffix "-1" instead of "-2").

<!-- this is only a snippet -->
<nav>
<ul>
<li><a href="#heading">heading</a></li>
<li><a href="#heading-1">heading</a></li>
</ul>
</nav>

Fixes #38

mrdrogdrog commented 3 years ago

Are there any news? We need this change (and a release) for https://github.com/codimd/react-client/pull/642 :/

mrdrogdrog commented 3 years ago

@nagaozen Please let us know if you have time to review the open PRs and create a new release. We need this fixes. If you don't have time, then let us know and we'll fork the project to apply the PRs ourself.

nagaozen commented 3 years ago

@mrdrogdrog Sincerely apologize, I'll take a look tonight. This project is tightly coupled with markdown-it-anchor so I'll review both packages and release'em.

nagaozen commented 3 years ago

i'd to update the name of the option to uniqueSlugStartIndex to follow the markdown-it-anchor options.