Fix some issues with ToC (#8797)
* Allow HTML in ToC Fixes #4793 * Extract ToC id from the header This is needed when the id is set explicitly in markdown.
This commit is contained in:
committed by
k8s-ci-robot
parent
200857de80
commit
a7d2dfc4fc
@@ -9,8 +9,10 @@
|
||||
{{ $section := $.ctx.Scratch.Get "section" }}
|
||||
{{ $headers := findRE "<h2.*?>(.|\n)*?</h2>" $section }}
|
||||
{{ range $headers }}
|
||||
{{ $header := . | replaceRE "</?h2.*?>" "" | htmlUnescape }}
|
||||
<li><a href="#{{ $header | anchorize }}">{{ $header }}</a></li>
|
||||
{{ $id := . | strings.TrimPrefix "<h2 id=\"" }}
|
||||
{{ $id := $id | replaceRE "\">.*" "" }}
|
||||
{{ $header := . | replaceRE "</?h2.*?>" "" | htmlUnescape | safeHTML }}
|
||||
<li><a href="#{{ $id }}">{{ $header }}</a></li>
|
||||
{{ end }}
|
||||
{{ $.ctx.Scratch.Add "sections" $section }}
|
||||
{{ end }}
|
||||
|
||||
Reference in New Issue
Block a user