{% macro toc(page, header) %}
{%- set toc_levels = page.extra.toc_levels | default(value=3) -%}
{% if toc_ignore_pattern %}
{%- set toc_ignore_pattern = page.extra.toc_ignore_pattern -%}
{% endif %}
{% if header %}
{%- if lang != config.default_language %} {{ trans(key="table_of_contents" | safe, lang=lang) }} {% else %} Table of Contents {% endif %}
{% endif %}
{% for h1 in page.toc %}
{# Only render headers if there's no ignore pattern, or if the header text doesn't match the pattern. #}
{% if not toc_ignore_pattern or not (h1.title is matching(toc_ignore_pattern)) %}