| {% capture tocWorkspace %} |
| {% comment %} |
| Version 1.0.8 |
| https://github.com/allejo/jekyll-toc |
| {% endcomment %} |
| |
| {% capture my_toc %}{% endcapture %} |
| {% assign orderedList = include.ordered | default: false %} |
| {% assign minHeader = include.h_min | default: 1 %} |
| {% assign maxHeader = include.h_max | default: 6 %} |
| {% assign nodes = include.html | split: '<h' %} |
| {% assign firstHeader = true %} |
| |
| {% capture listModifier %}{% if orderedList %}1.{% else %}-{% endif %}{% endcapture %} |
| |
| {% for node in nodes %} |
| {% if node == "" %} |
| {% continue %} |
| {% endif %} |
| |
| {% assign headerLevel = node | replace: '"', '' | slice: 0, 1 | times: 1 %} |
| |
| {% if headerLevel < minHeader or headerLevel > maxHeader %} |
| {% continue %} |
| {% endif %} |
| |
| {% if firstHeader %} |
| {% assign firstHeader = false %} |
| {% assign minHeader = headerLevel %} |
| {% endif %} |
| |
| {% assign indentAmount = headerLevel | minus: minHeader %} |
| {% assign _workspace = node | split: '</h' %} |
| |
| {% assign _idWorkspace = _workspace[0] | split: 'id="' %} |
| {% assign _idWorkspace = _idWorkspace[1] | split: '"' %} |
| {% assign html_id = _idWorkspace[0] %} |
| |
| {% assign _classWorkspace = _workspace[0] | split: 'class="' %} |
| {% assign _classWorkspace = _classWorkspace[1] | split: '"' %} |
| {% assign html_class = _classWorkspace[0] %} |
| |
| {% if html_class contains "no_toc" %} |
| {% continue %} |
| {% endif %} |
| |
| {% capture _hAttrToStrip %}{{ _workspace[0] | split: '>' | first }}>{% endcapture %} |
| {% assign header = _workspace[0] | replace: _hAttrToStrip, '' %} |
| |
| {% assign space = '' %} |
| {% for i in (1..indentAmount) %} |
| {% assign space = space | prepend: ' ' %} |
| {% endfor %} |
| |
| {% unless include.item_class == blank %} |
| {% capture listItemClass %}{:.{{ include.item_class | replace: '%level%', headerLevel }}}{% endcapture %} |
| {% endunless %} |
| |
| {% capture heading_body %}{% if include.sanitize %}{{ header | strip_html }}{% else %}{{ header }}{% endif %}{% endcapture %} |
| {% capture my_toc %}{{ my_toc }} |
| {{ space }}{{ listModifier }} {{ listItemClass }} [{{ heading_body | replace: "|", "\|" }}]({% if include.baseurl %}{{ include.baseurl }}{% endif %}#{{ html_id }}){% if include.anchor_class %}{:.{{ include.anchor_class }}}{% endif %}{% endcapture %} |
| {% endfor %} |
| |
| {% if include.class %} |
| {% capture my_toc %}{:.{{ include.class }}} |
| {{ my_toc | lstrip }}{% endcapture %} |
| {% endif %} |
| |
| {% if include.id %} |
| {% capture my_toc %}{: #{{ include.id }}} |
| {{ my_toc | lstrip }}{% endcapture %} |
| {% endif %} |
| {% endcapture %}{% assign tocWorkspace = '' %} |
| |
| <div class="content-toc"> |
| <div class="menu"> |
| <p class="menu-label">{{ include.content-toc-title }}</p> |
| {{ my_toc | markdownify | strip }} |
| </div> |
| </div> |