Skip to content

Commit 52b584f

Browse files
authored
Added urlencode to fix # in custom icons (#8087)
When using custom SVGs that contained characters breaking a URL, like a hash # sign that is consiered a URL fragment, the rendering broke. This adds a jinja urlencode filter to the output. Fixes #8086
1 parent 3296cdf commit 52b584f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

material/templates/partials/icons.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{% set _ = style.append(
99
"--md-admonition-icon--" ~ type ~ ":" ~
1010
"url('data:image/svg+xml;charset=utf-8," ~
11-
icon | replace("\n", "") ~
11+
icon | replace("\n", "") | urlencode ~
1212
"');"
1313
) %}
1414
{% endfor %}
@@ -21,7 +21,7 @@
2121
{% set _ = style.append(
2222
"--md-annotation-icon:" ~
2323
"url('data:image/svg+xml;charset=utf-8," ~
24-
icon | replace("\n", "") ~
24+
icon | replace("\n", "") | urlencode ~
2525
"');"
2626
) %}
2727
{% set _ = style.append("}\x3c/style\x3e") %}
@@ -38,7 +38,7 @@
3838
".md-tag" ~ modifier ~ "{" ~
3939
"--md-tag-icon:" ~
4040
"url('data:image/svg+xml;charset=utf-8," ~
41-
icon | replace("\n", "") ~
41+
icon | replace("\n", "") | urlencode ~
4242
"');" ~
4343
"}"
4444
) %}

src/templates/partials/icons.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
{% set _ = style.append(
2929
"--md-admonition-icon--" ~ type ~ ":" ~
3030
"url('data:image/svg+xml;charset=utf-8," ~
31-
icon | replace("\n", "") ~
31+
icon | replace("\n", "") | urlencode ~
3232
"');"
3333
) %}
3434
{% endfor %}
@@ -43,7 +43,7 @@
4343
{% set _ = style.append(
4444
"--md-annotation-icon:" ~
4545
"url('data:image/svg+xml;charset=utf-8," ~
46-
icon | replace("\n", "") ~
46+
icon | replace("\n", "") | urlencode ~
4747
"');"
4848
) %}
4949
{% set _ = style.append("}\x3c/style\x3e") %}
@@ -62,7 +62,7 @@
6262
".md-tag" ~ modifier ~ "{" ~
6363
"--md-tag-icon:" ~
6464
"url('data:image/svg+xml;charset=utf-8," ~
65-
icon | replace("\n", "") ~
65+
icon | replace("\n", "") | urlencode ~
6666
"');" ~
6767
"}"
6868
) %}

0 commit comments

Comments
 (0)