mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2026-08-01 18:28:48 -04:00
Fixed last minijinja compat issues in templates
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
-#}
|
||||
{% include "partials/tags.html" %}
|
||||
{% include "partials/actions.html" %}
|
||||
{% if "\x3ch1" not in page.content %}
|
||||
{% if "\u003ch1" not in page.content %}
|
||||
<h1>{{ page.title | d(config.site_name, true)}}</h1>
|
||||
{% endif %}
|
||||
{{ page.content }}
|
||||
|
||||
@@ -2,21 +2,23 @@
|
||||
This file was automatically generated - do not edit
|
||||
-#}
|
||||
{% if config.theme.icon.admonition %}
|
||||
{% set _ = namespace(style = "\x3cstyle\x3e:root{") %}
|
||||
{% set _ = namespace(style = "\u003cstyle\u003e:root{") %}
|
||||
{% for type, icon in config.theme.icon.admonition | items %}
|
||||
{% import ".icons/" ~ icon ~ ".svg" as icon %}
|
||||
{% set _.style = _.style ~
|
||||
"--md-admonition-icon--" ~ type ~ ":" ~
|
||||
"url('data:image/svg+xml;charset=utf-8," ~
|
||||
icon | replace("\n", "") | urlencode ~
|
||||
"');"
|
||||
%}
|
||||
{% if type and icon %}
|
||||
{% import ".icons/" ~ icon ~ ".svg" as icon %}
|
||||
{% set _.style = _.style ~
|
||||
"--md-admonition-icon--" ~ type ~ ":" ~
|
||||
"url('data:image/svg+xml;charset=utf-8," ~
|
||||
icon | replace("\n", "") | urlencode ~
|
||||
"');"
|
||||
%}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% set _.style = _.style ~ "}\x3c/style\x3e" %}
|
||||
{% set _.style = _.style ~ "}\u003c/style\u003e" %}
|
||||
{{ _.style }}
|
||||
{% endif %}
|
||||
{% if config.theme.icon.annotation %}
|
||||
{% set _ = namespace(style = "\x3cstyle\x3e:root{") %}
|
||||
{% set _ = namespace(style = "\u003cstyle\u003e:root{") %}
|
||||
{% import ".icons/" ~ config.theme.icon.annotation ~ ".svg" as icon %}
|
||||
{% set _.style = _.style ~
|
||||
"--md-annotation-icon:" ~
|
||||
@@ -24,25 +26,27 @@
|
||||
icon | replace("\n", "") | urlencode ~
|
||||
"');"
|
||||
%}
|
||||
{% set _.style = _.style ~ "}\x3c/style\x3e" %}
|
||||
{% set _.style = _.style ~ "}\u003c/style\u003e" %}
|
||||
{{ _.style }}
|
||||
{% endif %}
|
||||
{% if config.theme.icon.tag %}
|
||||
{% set _ = namespace(style = "\x3cstyle\x3e:root{") %}
|
||||
{% set _ = namespace(style = "\u003cstyle\u003e:root{") %}
|
||||
{% for type, icon in config.theme.icon.tag | items %}
|
||||
{% import ".icons/" ~ icon ~ ".svg" as icon %}
|
||||
{% if type != "default" %}
|
||||
{% set modifier = ".md-tag--" ~ type %}
|
||||
{% if type and icon %}
|
||||
{% import ".icons/" ~ icon ~ ".svg" as icon %}
|
||||
{% if type != "default" %}
|
||||
{% set modifier = ".md-tag--" ~ type %}
|
||||
{% endif %}
|
||||
{% set _.style = _.style ~
|
||||
".md-tag" ~ modifier ~ "{" ~
|
||||
"--md-tag-icon:" ~
|
||||
"url('data:image/svg+xml;charset=utf-8," ~
|
||||
icon | replace("\n", "") | urlencode ~
|
||||
"');" ~
|
||||
"}"
|
||||
%}
|
||||
{% endif %}
|
||||
{% set _.style = _.style ~
|
||||
".md-tag" ~ modifier ~ "{" ~
|
||||
"--md-tag-icon:" ~
|
||||
"url('data:image/svg+xml;charset=utf-8," ~
|
||||
icon | replace("\n", "") | urlencode ~
|
||||
"');" ~
|
||||
"}"
|
||||
%}
|
||||
{% endfor %}
|
||||
{% set _.style = _.style ~ "}\x3c/style\x3e" %}
|
||||
{% set _.style = _.style ~ "}\u003c/style\u003e" %}
|
||||
{{ _.style }}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
{#-
|
||||
This file was automatically generated - do not edit
|
||||
-#}
|
||||
{% macro split_and_get(value, sep, index) %}
|
||||
{%- if value.split is defined -%}
|
||||
{%- set parts = value.split(sep) -%}
|
||||
{%- else -%}
|
||||
{%- set parts = value | split(sep) -%}
|
||||
{%- endif -%}
|
||||
{{- parts[index] -}}
|
||||
{% endmacro %}
|
||||
<div class="md-social">
|
||||
{% for social in config.extra.social %}
|
||||
{% set rel = "noopener" %}
|
||||
@@ -9,8 +17,8 @@
|
||||
{% endif %}
|
||||
{% set title = social.name %}
|
||||
{% if not title and "//" in social.link %}
|
||||
{% set (_, url) = social.link.split("//") %}
|
||||
{% set title = url.split("/") | first %}
|
||||
{% set url = split_and_get(social.link, "//", 1) %}
|
||||
{% set title = split_and_get(url, "/", 0) %}
|
||||
{% endif %}
|
||||
<a href="{{ social.link }}" target="_blank" rel="{{ rel }}" title="{{ title | e }}" class="md-social__link">
|
||||
{% include ".icons/" ~ social.icon ~ ".svg" %}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
Hack: check whether the content contains a h1 headline. If it doesn't, the
|
||||
page title (or respectively site name) is used as the main headline.
|
||||
-->
|
||||
{% if "\x3ch1" not in page.content %}
|
||||
{% if "\u003ch1" not in page.content %}
|
||||
<h1>{{ page.title | d(config.site_name, true)}}</h1>
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -22,23 +22,25 @@
|
||||
|
||||
<!-- Custom admonition icons -->
|
||||
{% if config.theme.icon.admonition %}
|
||||
{% set _ = namespace(style = "\x3cstyle\x3e:root{") %}
|
||||
{% set _ = namespace(style = "\u003cstyle\u003e:root{") %}
|
||||
{% for type, icon in config.theme.icon.admonition | items %}
|
||||
{% import ".icons/" ~ icon ~ ".svg" as icon %}
|
||||
{% set _.style = _.style ~
|
||||
"--md-admonition-icon--" ~ type ~ ":" ~
|
||||
"url('data:image/svg+xml;charset=utf-8," ~
|
||||
icon | replace("\n", "") | urlencode ~
|
||||
"');"
|
||||
%}
|
||||
{% if type and icon %}
|
||||
{% import ".icons/" ~ icon ~ ".svg" as icon %}
|
||||
{% set _.style = _.style ~
|
||||
"--md-admonition-icon--" ~ type ~ ":" ~
|
||||
"url('data:image/svg+xml;charset=utf-8," ~
|
||||
icon | replace("\n", "") | urlencode ~
|
||||
"');"
|
||||
%}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% set _.style = _.style ~ "}\x3c/style\x3e" %}
|
||||
{% set _.style = _.style ~ "}\u003c/style\u003e" %}
|
||||
{{ _.style }}
|
||||
{% endif %}
|
||||
|
||||
<!-- Custom annotation icon -->
|
||||
{% if config.theme.icon.annotation %}
|
||||
{% set _ = namespace(style = "\x3cstyle\x3e:root{") %}
|
||||
{% set _ = namespace(style = "\u003cstyle\u003e:root{") %}
|
||||
{% import ".icons/" ~ config.theme.icon.annotation ~ ".svg" as icon %}
|
||||
{% set _.style = _.style ~
|
||||
"--md-annotation-icon:" ~
|
||||
@@ -46,27 +48,29 @@
|
||||
icon | replace("\n", "") | urlencode ~
|
||||
"');"
|
||||
%}
|
||||
{% set _.style = _.style ~ "}\x3c/style\x3e" %}
|
||||
{% set _.style = _.style ~ "}\u003c/style\u003e" %}
|
||||
{{ _.style }}
|
||||
{% endif %}
|
||||
|
||||
<!-- Custom tag icons -->
|
||||
{% if config.theme.icon.tag %}
|
||||
{% set _ = namespace(style = "\x3cstyle\x3e:root{") %}
|
||||
{% set _ = namespace(style = "\u003cstyle\u003e:root{") %}
|
||||
{% for type, icon in config.theme.icon.tag | items %}
|
||||
{% import ".icons/" ~ icon ~ ".svg" as icon %}
|
||||
{% if type != "default" %}
|
||||
{% set modifier = ".md-tag--" ~ type %}
|
||||
{% if type and icon %}
|
||||
{% import ".icons/" ~ icon ~ ".svg" as icon %}
|
||||
{% if type != "default" %}
|
||||
{% set modifier = ".md-tag--" ~ type %}
|
||||
{% endif %}
|
||||
{% set _.style = _.style ~
|
||||
".md-tag" ~ modifier ~ "{" ~
|
||||
"--md-tag-icon:" ~
|
||||
"url('data:image/svg+xml;charset=utf-8," ~
|
||||
icon | replace("\n", "") | urlencode ~
|
||||
"');" ~
|
||||
"}"
|
||||
%}
|
||||
{% endif %}
|
||||
{% set _.style = _.style ~
|
||||
".md-tag" ~ modifier ~ "{" ~
|
||||
"--md-tag-icon:" ~
|
||||
"url('data:image/svg+xml;charset=utf-8," ~
|
||||
icon | replace("\n", "") | urlencode ~
|
||||
"');" ~
|
||||
"}"
|
||||
%}
|
||||
{% endfor %}
|
||||
{% set _.style = _.style ~ "}\x3c/style\x3e" %}
|
||||
{% set _.style = _.style ~ "}\u003c/style\u003e" %}
|
||||
{{ _.style }}
|
||||
{% endif %}
|
||||
|
||||
@@ -20,6 +20,25 @@
|
||||
IN THE SOFTWARE.
|
||||
-->
|
||||
|
||||
<!--
|
||||
Split a string with a separator - while Jinja allows to call ".split" on a
|
||||
string, it doesn't natively bring a "split" filter implementation. We can't
|
||||
simply add further filters, since MkDocs doesn't allow it, so we're stuck
|
||||
with the function call. This however doesn't work with minijinja, which does
|
||||
not allow to call functions on template variables, but has a "split" filter.
|
||||
Thus, we just branch and extract the part that interests us here.
|
||||
-->
|
||||
{% macro split_and_get(value, sep, index) %}
|
||||
{%- if value.split is defined -%}
|
||||
{%- set parts = value.split(sep) -%}
|
||||
{%- else -%}
|
||||
{%- set parts = value | split(sep) -%}
|
||||
{%- endif -%}
|
||||
{{- parts[index] -}}
|
||||
{% endmacro %}
|
||||
|
||||
<!-- ---------------------------------------------------------------------- -->
|
||||
|
||||
<!-- Social links -->
|
||||
<div class="md-social">
|
||||
{% for social in config.extra.social %}
|
||||
@@ -33,8 +52,8 @@
|
||||
<!-- Compute title and render link -->
|
||||
{% set title = social.name %}
|
||||
{% if not title and "//" in social.link %}
|
||||
{% set (_, url) = social.link.split("//") %}
|
||||
{% set title = url.split("/") | first %}
|
||||
{% set url = split_and_get(social.link, "//", 1) %}
|
||||
{% set title = split_and_get(url, "/", 0) %}
|
||||
{% endif %}
|
||||
<a
|
||||
href="{{ social.link }}"
|
||||
|
||||
Reference in New Issue
Block a user