diff --git a/_includes/toc.html b/_includes/toc.html index bb45d1b..9c8cdc6 100644 --- a/_includes/toc.html +++ b/_includes/toc.html @@ -1,6 +1,6 @@ {% capture tocWorkspace %} {% comment %} - Version 1.0.6 + Version 1.0.7 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 @@ -59,6 +59,14 @@ {% 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, '' %} diff --git a/_tests/noTocClass.md b/_tests/noTocClass.md new file mode 100644 index 0000000..6529121 --- /dev/null +++ b/_tests/noTocClass.md @@ -0,0 +1,31 @@ +--- +# see https://github.com/allejo/jekyll-toc/issues/15 +--- + +{% capture markdown %} +# Contents header +{:.no_toc} + +* A markdown unordered list which will be replaced with the ToC, excluding the "Contents header" from above +{:toc} + +# H1 header + +## H2 header +{% endcapture %} +{% assign text = markdown | markdownify %} + +{% include toc.html html=text %} + + + + diff --git a/_tests/noTocClassMultipleClasses.md b/_tests/noTocClassMultipleClasses.md new file mode 100644 index 0000000..09cae03 --- /dev/null +++ b/_tests/noTocClassMultipleClasses.md @@ -0,0 +1,34 @@ +--- +# If a heading has `no_toc` with other classes, it should still ignore it from +# the TOC +# see https://github.com/allejo/jekyll-toc/issues/15 +--- + +{% capture markdown %} +# Contents header +{:.no_toc.another-class} + +* A markdown unordered list which will be replaced with the ToC, excluding the "Contents header" from above +{:toc} + +# H1 header +{:.custom-class} + +## H2 header +{% endcapture %} +{% assign text = markdown | markdownify %} + +{% include toc.html html=text %} + + + +