Skip to content

Commit 3f978d8

Browse files
committed
Strip tags of ToC item's aria label
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.
1 parent 2cff287 commit 3f978d8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

material/partials/toc-item.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{{ toc_item.title }}
77
</a>
88
{% if toc_item.children %}
9-
<nav class="md-nav" aria-label="{{ toc_item.title }}">
9+
<nav class="md-nav" aria-label="{{ toc_item.title | striptags }}">
1010
<ul class="md-nav__list">
1111
{% for toc_item in toc_item.children %}
1212
{% include "partials/toc-item.html" %}

src/partials/toc-item.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
<!-- Table of contents list -->
3030
{% if toc_item.children %}
31-
<nav class="md-nav" aria-label="{{ toc_item.title }}">
31+
<nav class="md-nav" aria-label="{{ toc_item.title | striptags }}">
3232
<ul class="md-nav__list">
3333
{% for toc_item in toc_item.children %}
3434
{% include "partials/toc-item.html" %}

0 commit comments

Comments
 (0)