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
This commit is contained in:
Adrian Föder
2025-03-14 10:00:35 +01:00
committed by GitHub
parent 3296cdf203
commit 52b584f9cb
2 changed files with 6 additions and 6 deletions

View File

@@ -8,7 +8,7 @@
{% set _ = style.append(
"--md-admonition-icon--" ~ type ~ ":" ~
"url('data:image/svg+xml;charset=utf-8," ~
icon | replace("\n", "") ~
icon | replace("\n", "") | urlencode ~
"');"
) %}
{% endfor %}
@@ -21,7 +21,7 @@
{% set _ = style.append(
"--md-annotation-icon:" ~
"url('data:image/svg+xml;charset=utf-8," ~
icon | replace("\n", "") ~
icon | replace("\n", "") | urlencode ~
"');"
) %}
{% set _ = style.append("}\x3c/style\x3e") %}
@@ -38,7 +38,7 @@
".md-tag" ~ modifier ~ "{" ~
"--md-tag-icon:" ~
"url('data:image/svg+xml;charset=utf-8," ~
icon | replace("\n", "") ~
icon | replace("\n", "") | urlencode ~
"');" ~
"}"
) %}

View File

@@ -28,7 +28,7 @@
{% set _ = style.append(
"--md-admonition-icon--" ~ type ~ ":" ~
"url('data:image/svg+xml;charset=utf-8," ~
icon | replace("\n", "") ~
icon | replace("\n", "") | urlencode ~
"');"
) %}
{% endfor %}
@@ -43,7 +43,7 @@
{% set _ = style.append(
"--md-annotation-icon:" ~
"url('data:image/svg+xml;charset=utf-8," ~
icon | replace("\n", "") ~
icon | replace("\n", "") | urlencode ~
"');"
) %}
{% set _ = style.append("}\x3c/style\x3e") %}
@@ -62,7 +62,7 @@
".md-tag" ~ modifier ~ "{" ~
"--md-tag-icon:" ~
"url('data:image/svg+xml;charset=utf-8," ~
icon | replace("\n", "") ~
icon | replace("\n", "") | urlencode ~
"');" ~
"}"
) %}