Commit a3d7343a authored by Vincent Tam's avatar Vincent Tam

TOC : fixed gohugoio/hugo#1778 again

parent 8dc3e70d
{{ if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) }}
{{ $toc := .TableOfContents }}
{{ $toc := (replace $toc "<ul>\n<li>\n<ul>" "<ul>") }}
{{ $toc := (replace $toc "<ul>\n<li>\n<ul>" "<ul>") }}
{{ $toc := (replace $toc "<ul>\n<li>\n<ul>" "<ul>") }}
{{ $toc := (replace $toc "</ul></li>\n</ul>" "</ul>") }}
{{ $toc := (replace $toc "</ul></li>\n</ul>" "</ul>") }}
{{ $toc := (replace $toc "</ul></li>\n</ul>" "</ul>") }}
<!-- count the number of remaining li tags -->
<!-- and only display ToC if more than 1, otherwise why bother -->
{{ if gt (len (split $toc "<li>")) 2 }}
<aside class="toc-article">
{{ safeHTML $toc }}
</aside>
{{ end }}
{{ $emtLiPtrn := "(?s)<ul>\\s*<li>\\s*<ul>(.*)</li>\\s*</ul>" }}
{{ $rplcEmtLi := "<ul>$1" }}
{{ .TableOfContents | replaceRE $emtLiPtrn $rplcEmtLi | safeHTML }}
{{- end }}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment