{# Kopf- und Fusszeile. Beide Bloecke stehen hier im Body, werden durch
position: running() aber aus dem Fluss genommen und erscheinen nur in der
Margin-Box -- nie im Text.
Der Weg ueber Running Elements statt ueber eine content-Zeichenkette ist
der Grund, warum hier echtes Markup moeglich ist: der Dokumenttitel fett,
der Untertitel normal. Eine content-Zeichenkette kennt nur eine
Formatierung fuer alle ihre Zeilen.
Zeilenzahl geaendert? Dann hf_header_lines / hf_footer_lines in styles.css
mitziehen -- daraus wird der Seitenrand gerechnet. #}
{% if document.header %}
{{ document.title }}
{% if document.subtitle %}
{{ document.subtitle }}
{% endif %}
{# Kapiteltitel: kommt aus dem string-set der Kapitel weiter unten. #}
{% endif %}
{% if document.footer %}
{% endif %}
{# Rendert ein Kapitel samt aller Unterkapitel. Der Selbstaufruf am Ende ist
entscheidend: ohne ihn fallen verschachtelte Unterkapitel aus der Ausgabe,
obwohl ihre Ueberschriften im Inhaltsverzeichnis stehen.
Der Bezeichner in string-set muss exakt dem string() in styles.css
entsprechen (.hf-section::before) -- current-section, nicht
current_section. #}
{% macro render_chapter(item, section_label) %}
{% if item.has_divider_page %}
{% with chapter = item %}
{% include "chapter_divider.html" %}
{% endwith %}
{% endif %}
{{ item.html_content | safe }}
{% for child in item.children %}
{{ render_chapter(child, section_label ~ " – " ~ child.display_title) }}
{% endfor %}
{% endmacro %}
{# 1. Deckblatt (Cover) #}
{% if document.cover %}
{% include "cover.html" %}
{% endif %}
{# 2. Globales Inhaltsverzeichnis (TOC) #}
{% if document.document_toc and toc_tree %}
{% include "toc.html" %}
{% endif %}
{# 3. Hauptinhalt: Parts und Kapitel #}
{% for item in content_items %}
{% if item.is_part %}
{% if item.has_divider_page %}
{% with part = item %}
{% include "part_divider.html" %}
{% endwith %}
{% endif %}
{% for child in item.children %}
{{ render_chapter(child, item.title ~ " – " ~ child.display_title) }}
{% endfor %}
{% else %}
{{ render_chapter(item, item.display_title) }}
{% endif %}
{% endfor %}