File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ gem "minima", "~> 2.5"
1717group :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"
2121end
2222
2323# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
Original file line number Diff line number Diff line change 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 )
You can’t perform that action at this time.
0 commit comments