Strip tags of ToC item's aria label#5536
Conversation
squidfunk
left a comment
There was a problem hiding this comment.
Thanks! Sounds legit, as previously discussed via Gitter. Some minor adjustments.
src/partials/toc-item.html
Outdated
| <!-- Table of contents list --> | ||
| {% if toc_item.children %} | ||
| <nav class="md-nav" aria-label="{{ toc_item.title }}"> | ||
| <nav class="md-nav" aria-label="{{ toc_item.title|striptags }}"> |
There was a problem hiding this comment.
Please stick to our code style and insert spaces left and right to the | pipe material folder, or they won't be picked up.
|
I ran |
|
Thanks! You need to run |
|
Oh OK, this wasn't clear to me from the docs:
I understood this as "use build:all if you have a custom fork of the theme" (I don't, I'm just sending a PR). |
|
Okay, sorry, last thing: the iconsearch index got deleted - please remove that from the commit as well. This is likely because the emoji database wasn't found in the virtual environment (we kind of assume that mkdocs-material/tools/build/index.ts Line 276 in 2cff287 This is a shortcoming of our current build process. We're going to revamp the docs and the process in the near future. |
|
Sure, no worries! Indeed I usually use |
Some plugins/extensions might use the data-toc-label attribute of headings to set a particular string for the ToC item title. While not explicitly documented as possible or allowed, they might set some HTML code instead of text. In this case, the aria label of Toc nav elements break the HTML as they will contain unescaped double quotes. To fix this, we use the `striptags` filter to remove any tags from the aria label, keeping text only.
|
Perfect, good to go now! |
Some plugins/extensions might use the data-toc-label attribute of headings to set a particular string for the ToC item title.
While not explicitly documented as possible or allowed, they might set some HTML code instead of text. In this case, the aria label of Toc nav elements break the HTML as they will contain unescaped double quotes.
To fix this, we use the
striptagsfilter to remove any tags from the aria label, keeping text only.