<!--
  ~    Copyright 2016-present CERN – European Organization for Nuclear Research
  ~
  ~    Licensed under the Apache License, Version 2.0 (the "License");
  ~    you may not use this file except in compliance with the License.
  ~    You may obtain a copy of the License at
  ~
  ~        http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~    Unless required by applicable law or agreed to in writing, software
  ~    distributed under the License is distributed on an "AS IS" BASIS,
  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~    See the License for the specific language governing permissions and
  ~    limitations under the License.
  -->

<h1 style="text-align: center">Contents</h1>
<div class="index">
    {% for element in elements %} {% for i in range(1, element.level+1) %}
    <!-- Generate <ul> and <li> tags for each level (to indent the text) -->
    {% if i != element.level %}
    <ul>
        <li>
            {% else %}
            <ul class="present">
                <li>
                    <!-- Add a hyperlink to the element only if we are at its level. -->
                    <a href="#{{ element.id }}">{{element.text}}</a>
                    <!-- Generate the necessary closing tags -->
                    {% for _ in range(i) %}
                </li>
            </ul>
            {% endfor %} {% endif %} {% endfor %} {% endfor %}
</div>
<p style="page-break-before: always"></p>
<!-- Force a page break -->