Compatibility with toc permalinks (section numbers are duplicated)
Closed this issue · 5 comments
When using a toc configuration like this:
markdown_extensions:
- toc:
permalink: true
plugins:
- enumerate-headings:
toc_depth: 4
The headings end up with duplicate section numbers in the permalink itself. For example:
<h2 id="table-of-contents"><span class="enumerate-heading-plugin">1.1</span> Table of Contents<a class="headerlink" href="#table-of-contents" title="Permanent link">1.1 ¶</a></h2>
I believe this is caused by this function:
Which iterates every anchor on the page that links to the section instead of only iterating over anchors in the nav bar. I was able to work around this using anchorlinks instead of permalinks plus extra CSS to hide the enumerate-heading-plugin span.
Thanks for reporting the issue! Will look into it, just things are a bit slower during the summer period ;)
No worries, it's not blocking my use of this very useful extension.
Fixed in v0.4.3
I would be interested to hear about your use-case for this plugin?
I'm using it with my team for writing technical reports. Today I released an update to mkdocs-print-site-plugin that also enumerates headings, which makes this plugin slightly less useful for me.
Works great, thanks!
We're using the extension for a "handbook" that we'll be adding content to over time. So our use-case is to be able to insert sections and "chapters" without needing to go back and renumber existing content. Due to the potential length and variety of content, I don't know if we would want to generate a "site page".
Cool, thanks!