Update jekyll-toc to v1.0.5
This commit is contained in:
parent
961d0b4db8
commit
07411719a0
1 changed files with 23 additions and 13 deletions
|
@ -1,6 +1,7 @@
|
||||||
{% capture tocWorkspace %}
|
{% capture tocWorkspace %}
|
||||||
{%- comment -%}
|
{% comment %}
|
||||||
Version 1.0.2
|
Version 1.0.5
|
||||||
|
https://github.com/allejo/jekyll-toc
|
||||||
|
|
||||||
"...like all things liquid - where there's a will, and ~36 hours to spare, there's usually a/some way" ~jaybe
|
"...like all things liquid - where there's a will, and ~36 hours to spare, there's usually a/some way" ~jaybe
|
||||||
|
|
||||||
|
@ -8,25 +9,31 @@
|
||||||
{% include toc.html html=content sanitize=true class="inline_toc" id="my_toc" h_min=2 h_max=3 %}
|
{% include toc.html html=content sanitize=true class="inline_toc" id="my_toc" h_min=2 h_max=3 %}
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
* html (string) - the HTML of compiled markdown generated by kramdown in Jekyll
|
* html (string) - the HTML of compiled markdown generated by kramdown in Jekyll
|
||||||
|
|
||||||
Optional Parameters:
|
Optional Parameters:
|
||||||
* sanitize (bool) : false - when set to true, the headers will be stripped of any HTML in the TOC
|
* sanitize (bool) : false - when set to true, the headers will be stripped of any HTML in the TOC
|
||||||
* class (string) : '' - a CSS class assigned to the TOC
|
* class (string) : '' - a CSS class assigned to the TOC
|
||||||
* id (string) : '' - an ID to assigned to the TOC
|
* id (string) : '' - an ID to assigned to the TOC
|
||||||
* h_min (int) : 1 - the minimum TOC header level to use; any header lower than this value will be ignored
|
* h_min (int) : 1 - the minimum TOC header level to use; any header lower than this value will be ignored
|
||||||
* h_max (int) : 6 - the maximum TOC header level to use; any header greater than this value will be ignored
|
* h_max (int) : 6 - the maximum TOC header level to use; any header greater than this value will be ignored
|
||||||
|
* ordered (bool) : false - when set to true, an ordered list will be outputted instead of an unordered list
|
||||||
|
* item_class (string) : '' - add custom class for each list item; has support for '%level%' placeholder, which is the current heading level
|
||||||
|
* baseurl (string) : '' - add a base url to the TOC links for when your TOC is on another page than the actual content
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
An unordered list representing the table of contents of a markdown block. This snippet will only generate the table of contents and will NOT output the markdown given to it
|
An ordered or unordered list representing the table of contents of a markdown block. This snippet will only generate the table of contents and will NOT output the markdown given to it
|
||||||
{%- endcomment -%}
|
{% endcomment %}
|
||||||
|
|
||||||
{% capture my_toc %}{% endcapture %}
|
{% capture my_toc %}{% endcapture %}
|
||||||
|
{% assign orderedList = include.ordered | default: false %}
|
||||||
{% assign minHeader = include.h_min | default: 1 %}
|
{% assign minHeader = include.h_min | default: 1 %}
|
||||||
{% assign maxHeader = include.h_max | default: 6 %}
|
{% assign maxHeader = include.h_max | default: 6 %}
|
||||||
{% assign nodes = include.html | split: '<h' %}
|
{% assign nodes = include.html | split: '<h' %}
|
||||||
{% assign firstHeader = true %}
|
{% assign firstHeader = true %}
|
||||||
|
|
||||||
|
{% capture listModifier %}{% if orderedList %}1.{% else %}-{% endif %}{% endcapture %}
|
||||||
|
|
||||||
{% for node in nodes %}
|
{% for node in nodes %}
|
||||||
{% if node == "" %}
|
{% if node == "" %}
|
||||||
{% continue %}
|
{% continue %}
|
||||||
|
@ -55,12 +62,15 @@
|
||||||
|
|
||||||
{% assign space = '' %}
|
{% assign space = '' %}
|
||||||
{% for i in (1..indentAmount) %}
|
{% for i in (1..indentAmount) %}
|
||||||
{% assign space = space | prepend: ' ' %}
|
{% assign space = space | prepend: ' ' %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% capture my_toc %}{{ my_toc }}
|
{% unless include.item_class == blank %}
|
||||||
{{ space }}- [{% if include.sanitize %}{{ header | strip_html }}{% else %}{{ header }}{% endif %}](#{{ html_id }}){% endcapture %}
|
{% capture listItemClass %}{:.{{ include.item_class | replace: '%level%', headerLevel }}}{% endcapture %}
|
||||||
|
{% endunless %}
|
||||||
|
|
||||||
|
{% capture my_toc %}{{ my_toc }}
|
||||||
|
{{ space }}{{ listModifier }} {{ listItemClass }} [{% if include.sanitize %}{{ header | strip_html }}{% else %}{{ header }}{% endif %}]({% if include.baseurl %}{{ include.baseurl }}{% endif %}#{{ html_id }}){% endcapture %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% if include.class %}
|
{% if include.class %}
|
||||||
|
|
Loading…
Add table
Reference in a new issue