From 13a13e771e4fb4ff1f0c0da403573caa675b0089 Mon Sep 17 00:00:00 2001 From: Vladimir Jimenez Date: Sat, 1 Aug 2020 17:17:10 -0700 Subject: [PATCH 1/2] Correctly split closing heading + content after --- _includes/anchor_headings.html | 14 ++++++++++++-- _tests/nestedHeadingsInHeader.html | 24 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 _tests/nestedHeadingsInHeader.html diff --git a/_includes/anchor_headings.html b/_includes/anchor_headings.html index 2030d90..8293de9 100644 --- a/_includes/anchor_headings.html +++ b/_includes/anchor_headings.html @@ -82,7 +82,8 @@ {% continue %} {% endif %} - {% assign _workspace = node | split: '{% endcapture %} + {% assign _workspace = node | split: _closingTag %} {% assign _idWorkspace = _workspace[0] | split: 'id="' %} {% assign _idWorkspace = _idWorkspace[1] | split: '"' %} {% assign html_id = _idWorkspace[0] %} @@ -127,8 +128,17 @@ {{ header }}{{ anchor }} {% endif %} {{ include.bodySuffix }} - {% endcapture %} + + + {% assign chunkCount = _workspace | size %} + {% if chunkCount > 1 %} + {% capture new_heading %}{{ new_heading }}{{ _workspace | last }}{% endcapture %} + {% endif %} + {% capture edited_headings %}{{ edited_headings }}{{ new_heading }}{% endcapture %} {% endfor %} {% endcapture %}{% assign headingsWorkspace = '' %}{{ edited_headings | strip }} diff --git a/_tests/nestedHeadingsInHeader.html b/_tests/nestedHeadingsInHeader.html new file mode 100644 index 0000000..e48bbe5 --- /dev/null +++ b/_tests/nestedHeadingsInHeader.html @@ -0,0 +1,24 @@ +--- +# https://github.com/allejo/jekyll-anchor-headings/issues/21 +--- + +{% capture markdown %} +
+

Goodbye World

+

some header text

+
+{% endcapture %} +{% assign text = markdown | markdownify %} + +
+{% include anchor_headings.html html=text %} +
+ + + +
+
+

Goodbye World

+

some header text

+
+
From f07b2b32cabe8b2f45fe5916fc8c3b6e0d14c3c6 Mon Sep 17 00:00:00 2001 From: Vladimir Jimenez Date: Sat, 1 Aug 2020 17:17:20 -0700 Subject: [PATCH 2/2] Version bump to 1.0.7 --- _includes/anchor_headings.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/anchor_headings.html b/_includes/anchor_headings.html index 8293de9..e9ca862 100644 --- a/_includes/anchor_headings.html +++ b/_includes/anchor_headings.html @@ -24,7 +24,7 @@ OTHER DEALINGS IN THE SOFTWARE. {% endcomment %} {% comment %} - Version 1.0.6 + Version 1.0.7 https://github.com/allejo/jekyll-anchor-headings "Be the pull request you wish to see in the world." ~Ben Balter