squidfunk / mkdocs-material

Documentation that simply works
https://squidfunk.github.io/mkdocs-material/
MIT License
20.3k stars 3.48k forks source link

Insiders tag plugin conflicts with markdown_extensions.toc #7191

Closed kcgthb closed 4 months ago

kcgthb commented 4 months ago

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

squidfunk commented 4 months ago

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.

kcgthb commented 4 months ago

Thank you for the quick fix! Much appreciated.

kcgthb commented 4 months ago

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

squidfunk commented 4 months ago

Great! Keeping open until released.

squidfunk commented 4 months ago

Released as part of 9.5.24+insiders-4.53.9.