-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strip tags of ToC item's aria label #5536
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Sounds legit, as previously discussed via Gitter. Some minor adjustments.
src/partials/toc-item.html
Outdated
@@ -28,7 +28,7 @@ | |||
|
|||
<!-- 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
striptags
filter to remove any tags from the aria label, keeping text only.