Skip to content

Commit b69de3f

Browse files
committed
next try to fix Actions with jekyll-toc
1 parent 6fad541 commit b69de3f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ gem "minima", "~> 2.5"
1717
group :jekyll_plugins do
1818
gem "jekyll-feed", "~> 0.12"
1919
# to create table of content for .md document
20-
gem 'jekyll-toc'
20+
gem "jekyll-toc"
2121
end
2222

2323
# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem

_plugins/TocFilter.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module TocFilter
2+
def toc(input)
3+
output = "<ol class=\"toc\">"
4+
input.scan(/<(h2)(?:>|\s+(.*?)>)([^<]*)<\/\1\s*>/mi).each do |entry|
5+
id = (entry[1][/^id=(['"])(.*)\1$/, 2] rescue nil)
6+
title = entry[2].gsub(/<(\w*).*?>(.*?)<\/\1\s*>/m, '\2').strip
7+
if id
8+
output << %{<li><a href="##{id}">#{title}</a></li>}
9+
else
10+
output << %{<li>#{title}</li>}
11+
end
12+
end
13+
output << '</ol>'
14+
output
15+
end
16+
end
17+
Liquid::Template.register_filter(TocFilter)

0 commit comments

Comments
 (0)