{# ============= #} {# === KATEX === #} {# ============= #} {% macro katex() %} {% endmacro katex %} {# =========================== #} {# === resize static image === #} {# =========================== #} {% macro resize_static(path, width=160, height=160, op="fit_height") %} {{ resize_image(path="../static" ~ path, width=width, height=height, op=op) }} {% 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 %}