Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
251 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
--- | ||
|
||
{% capture markdown %} | ||
# Heading 1 | ||
{% endcapture %} | ||
{% assign text = markdown | markdownify %} | ||
|
||
{% include toc.html html=text class="awesome-toc-class" %} | ||
|
||
<!-- /// --> | ||
|
||
<ul class="awesome-toc-class"> | ||
<li><a href="#heading-1">Heading 1</a></li> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
# Test the 'id' attribute correctly assigns the ID to the generated TOC | ||
--- | ||
|
||
{% capture markdown %} | ||
# Heading 1 | ||
{% endcapture %} | ||
{% assign text = markdown | markdownify %} | ||
|
||
{% include toc.html html=text id="Jekyll-TOC" %} | ||
|
||
<!-- /// --> | ||
|
||
<ul id="Jekyll-TOC"> | ||
<li><a href="#heading-1">Heading 1</a></li> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
# Given h_max is defined, it should only use headings less than or equal to this value | ||
--- | ||
|
||
{% capture markdown %} | ||
# Heading 1 | ||
|
||
## Heading 2.1 | ||
|
||
### Heading 3 | ||
|
||
#### Heading 4 | ||
|
||
## Heading 2.2 | ||
{% endcapture %} | ||
{% assign text = markdown | markdownify %} | ||
|
||
{% include toc.html html=text h_max=2 %} | ||
|
||
<!-- /// --> | ||
|
||
<ul> | ||
<li> | ||
<a href="#heading-1">Heading 1</a> | ||
<ul> | ||
<li><a href="#heading-21">Heading 2.1</a></li> | ||
<li><a href="#heading-22">Heading 2.2</a></li> | ||
</ul> | ||
</li> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
# Given h_min and h_max are both defined, the TOC should respect both | ||
--- | ||
|
||
{% capture markdown %} | ||
# Heading 1 | ||
|
||
## Heading 2.1 | ||
|
||
### Heading 3 | ||
|
||
#### Heading 4.1 | ||
|
||
#### Heading 4.2 | ||
|
||
##### Heading 5 | ||
|
||
## Heading 2.2 | ||
|
||
{% endcapture %} | ||
{% assign text = markdown | markdownify %} | ||
|
||
{% include toc.html html=text h_min=2 h_max=4 %} | ||
|
||
<!-- /// --> | ||
|
||
<ul> | ||
<li> | ||
<a href="#heading-21">Heading 2.1</a> | ||
<ul> | ||
<li> | ||
<a href="#heading-3">Heading 3</a> | ||
<ul> | ||
<li><a href="#heading-41">Heading 4.1</a></li> | ||
<li><a href="#heading-42">Heading 4.2</a></li> | ||
</ul> | ||
</li> | ||
</ul> | ||
</li> | ||
<li><a href="#heading-22">Heading 2.2</a></li> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
# Given h_min is defined, it should only use headings greater than or equal to this value | ||
--- | ||
|
||
{% capture markdown %} | ||
# Heading 1 | ||
|
||
## Heading 2.1 | ||
|
||
### Heading 3 | ||
|
||
#### Heading 4 | ||
|
||
## Heading 2.2 | ||
{% endcapture %} | ||
{% assign text = markdown | markdownify %} | ||
|
||
{% include toc.html html=text h_min=2 %} | ||
|
||
<!-- /// --> | ||
|
||
<ul> | ||
<li> | ||
<a href="#heading-21">Heading 2.1</a> | ||
<ul> | ||
<li> | ||
<a href="#heading-3">Heading 3</a> | ||
<ul> | ||
<li><a href="#heading-4">Heading 4</a></li> | ||
</ul> | ||
</li> | ||
</ul> | ||
</li> | ||
<li><a href="#heading-22">Heading 2.2</a></li> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
# Supporting multiple classes for the TOC works by concatenating them with periods | ||
--- | ||
|
||
{% capture markdown %} | ||
# Heading 1 | ||
{% endcapture %} | ||
{% assign text = markdown | markdownify %} | ||
|
||
{% include toc.html html=text class="first-class.second-class" %} | ||
|
||
<!-- /// --> | ||
|
||
<ul class="first-class second-class"> | ||
<li><a href="#heading-1">Heading 1</a></li> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
# Given a markdown block with no headings, no TOC will be generated | ||
--- | ||
|
||
{% capture markdown %} | ||
Some **awesome** markdown that doesn't have any headings | ||
{% endcapture %} | ||
{% assign text = markdown | markdownify %} | ||
|
||
<div id="unit-test"> | ||
{% include toc.html html=text id="Jekyll-TOC" %} | ||
</div> | ||
|
||
<!-- /// --> | ||
|
||
<div id="unit-test"> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
# Given `sanitize` is set to false, any HTML from headings should remain | ||
--- | ||
|
||
{% capture markdown %} | ||
# Heading 1 | ||
|
||
## `Heading` 2.1 | ||
|
||
### Heading **3** | ||
|
||
#### Heading _4_ | ||
|
||
## Heading 2.2 | ||
{% endcapture %} | ||
{% assign text = markdown | markdownify %} | ||
|
||
{% include toc.html html=text sanitize=false %} | ||
|
||
<!-- /// --> | ||
|
||
<ul> | ||
<li> | ||
<a href="#heading-1">Heading 1</a> | ||
<ul> | ||
<li> | ||
<a href="#heading-21"><code class="highlighter-rouge">Heading</code> 2.1</a> | ||
<ul> | ||
<li> | ||
<a href="#heading-3">Heading <strong>3</strong></a> | ||
<ul> | ||
<li><a href="#heading-4">Heading <em>4</em></a></li> | ||
</ul> | ||
</li> | ||
</ul> | ||
</li> | ||
<li><a href="#heading-22">Heading 2.2</a></li> | ||
</ul> | ||
</li> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
# Given `sanitize` is set to true, any HTML in the TOC should be stripped | ||
--- | ||
|
||
{% capture markdown %} | ||
# Heading 1 | ||
|
||
## `Heading` 2.1 | ||
|
||
### Heading **3** | ||
|
||
#### Heading _4_ | ||
|
||
## Heading 2.2 | ||
{% endcapture %} | ||
{% assign text = markdown | markdownify %} | ||
|
||
{% include toc.html html=text sanitize=true %} | ||
|
||
<!-- /// --> | ||
|
||
<ul> | ||
<li> | ||
<a href="#heading-1">Heading 1</a> | ||
<ul> | ||
<li> | ||
<a href="#heading-21">Heading 2.1</a> | ||
<ul> | ||
<li> | ||
<a href="#heading-3">Heading 3</a> | ||
<ul> | ||
<li><a href="#heading-4">Heading 4</a></li> | ||
</ul> | ||
</li> | ||
</ul> | ||
</li> | ||
<li><a href="#heading-22">Heading 2.2</a></li> | ||
</ul> | ||
</li> | ||
</ul> |