{# ============= #} {# === KATEX === #} {# ============= #} {% macro katex() %} {% endmacro katex %} {# =========================== #} {# === resize static image === #} {# =========================== #} {% macro resize_static(path, width=160, height=160, op="fit_height") %} {% set resized = resize_image(path="../static" ~ path, width=width, height=height, op=op) %} {{ resized.url }} {% endmacro resize_static %} {# ========================= #} {# === table of contents === #} {# ========================= #} {% macro toc(toc, level, depth) %} {%- if level == 1 %}

Table des matières

{%- endif %} {%- if level != 1 %}
    {%- endif %} {%- for h in toc %} {%- if level != 1 %}
  1. {{ h.title }} {%- endif %} {% if h.children and level <= depth -%} {{ self::toc(toc=h.children, level=level+1, depth=depth, heading=false) }} {%- endif %} {%- if level != 1 -%}
  2. {%- endif %} {%- endfor %} {%- if level != 1 %}
{%- endif %} {%- if level == 1 %}
{%- endif %} {%- endmacro %} {# =================== #} {# === replace toc === #} {# =================== #} {% macro replace_toc(resource) %} {%- set content = resource.content %} {%- if content is containing("[TOC]") %} {%- set content = content | replace(from="[TOC]", to=self::toc(toc=resource.toc, level=1, depth=resource.extra.toc_depth | default(value=6))) %} {%- endif -%} {{ content | safe }} {%- endmacro %} {# ================== #} {# === breadcrumb === #} {# ================== #} {% macro breadcrumb(path) %} {% set cur = "/" %} {% for elt in path %} {% set_global cur = cur ~ elt ~ "/" %} / {{ elt }} {% endfor %} {%- endmacro %} {# ================================= #} {# === sub pages and sub section === #} {# ================================= #} {% macro sub(section) %} content {%- endmacro %} {# === tags === #} {% macro tags(tags) %} {% for tag in tags %} {%- set url = get_taxonomy_url(kind="tags", name=tag) %} {{ tag }} {% endfor %} {%- endmacro %} {# === author === #} {% macro authors(authors) %} {% for author in authors %} {%- set url = get_taxonomy_url(kind="authors", name=author) %} {{ author }} {% endfor %} {%- endmacro %} {# === category === #} {% macro category(category) %} {% for cat in category %} {%- set url = get_taxonomy_url(kind="category", name=cat) %} {{ cat }} {% endfor %} {%- endmacro %} {# === taxonomies === #} {% macro taxonomies(taxonomies) %} {% if taxonomies.tags %}{{ macros::tags(tags=taxonomies.tags )}}{% endif %} {% if taxonomies.authors %}{{ macros::authors(authors=taxonomies.authors )}}{% endif %} {% if taxonomies.category %}{{ macros::category(category=taxonomies.category )}}{% endif %} {%- endmacro %}