From 52b584f9cbe85040841010533b56abb39b5b4052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20F=C3=B6der?= Date: Fri, 14 Mar 2025 10:00:35 +0100 Subject: [PATCH] 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 --- material/templates/partials/icons.html | 6 +++--- src/templates/partials/icons.html | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/material/templates/partials/icons.html b/material/templates/partials/icons.html index 5d903ed81..37da7364f 100644 --- a/material/templates/partials/icons.html +++ b/material/templates/partials/icons.html @@ -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 ~ "');" ~ "}" ) %} diff --git a/src/templates/partials/icons.html b/src/templates/partials/icons.html index d588d8241..2f267a229 100644 --- a/src/templates/partials/icons.html +++ b/src/templates/partials/icons.html @@ -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 ~ "');" ~ "}" ) %}