mkdocs-material icon indicating copy to clipboard operation
mkdocs-material copied to clipboard

Insiders tag plugin conflicts with markdown_extensions.toc

Open kcgthb opened this issue 9 months ago • 4 comments

Context

The new Insiders tag plugin rewrite conflicts with the markdown_extensions.toc extension.

Bug description

When the markdown_extensions.toc extension is used and toc_depth option is set to a value <6, the new Insiders tag plugin doesn't generate tag listings.

Related links

Reproduction

9.5.23+insiders.4.53.8-no-tags-list-with-toc.zip

Steps to reproduce

  1. enable plugins.tags in mkdocs.yml
  2. set markdown_extensions.tac.toc_depth: 6 in mkdocs.yml
  3. <!-- material/tags --> doesn't generate anything

Browser

No response

Before submitting

kcgthb avatar May 17 '24 01:05 kcgthb

Thanks for reporting! Fixed in 0f167caf4. The problem is that the tags plugin needs to somehow hook into the TOC generation, and it does so by just appending the maximum headline, so the tags listing is listed under the preceding headline. This is a pretty dirty hack, but otherwise, it would be much more difficult to pull this off, as we'd need to parse the Markdown again, and isolate which was the last headline before the tags listing.

When the maximum level is changed, it stops as reported. Now, the plugin will read the maximum level from the configuration of the table of contents extension and use that for injecting listings.

Is that the optimal solution? Very far from it, but we need to work with what Python Markdown and MkDocs gives us. We'll investigate in the future if we can improve the implementation and make it less hacky. I hope that in the meantime, the reported problem can be considered fixed.

squidfunk avatar May 17 '24 13:05 squidfunk

Thank you for the quick fix! Much appreciated.

kcgthb avatar May 17 '24 18:05 kcgthb

I can confirm that this commit resolves the issue for us, so closing this issue now.

kcgthb avatar May 17 '24 23:05 kcgthb

Great! Keeping open until released.

squidfunk avatar May 18 '24 06:05 squidfunk

Released as part of 9.5.24+insiders-4.53.9.

squidfunk avatar May 20 '24 11:05 squidfunk