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" }}
|
{{ $section := $.ctx.Scratch.Get "section" }}
|
||||||
{{ $headers := findRE "<h2.*?>(.|\n)*?</h2>" $section }}
|
{{ $headers := findRE "<h2.*?>(.|\n)*?</h2>" $section }}
|
||||||
{{ range $headers }}
|
{{ range $headers }}
|
||||||
{{ $header := . | replaceRE "</?h2.*?>" "" | htmlUnescape }}
|
{{ $id := . | strings.TrimPrefix "<h2 id=\"" }}
|
||||||
<li><a href="#{{ $header | anchorize }}">{{ $header }}</a></li>
|
{{ $id := $id | replaceRE "\">.*" "" }}
|
||||||
|
{{ $header := . | replaceRE "</?h2.*?>" "" | htmlUnescape | safeHTML }}
|
||||||
|
<li><a href="#{{ $id }}">{{ $header }}</a></li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ $.ctx.Scratch.Add "sections" $section }}
|
{{ $.ctx.Scratch.Add "sections" $section }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|||||||
Reference in New Issue
Block a user