Skip to content

Commit 99ed708

Browse files
authored
Fix TOC htmlentities rendering (#105)
1 parent 79cd915 commit 99ed708

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

extensions/toc/templates/toc.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{ define "toc-item" }}
22
<li>
3-
<a href="#{{ printf "%s" .ID}}">{{ printf "%s" .Title}}</a>
3+
<a href="#{{ printf "%s" .ID}}">{{ printf "%s" .Title | raw }}</a>
44
{{ with .Items }}
55
<ul class="menu-list">
66
{{ range . }}

helpers.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var helpers = template.FuncMap{
2828
"emoji": Emoji,
2929
"base": path.Base,
3030
"dir": dir,
31+
"raw": raw,
3132
}
3233

3334
var ErrHelperRegistered = errors.New("Helper already registered")
@@ -194,3 +195,8 @@ func dir(s string) string {
194195

195196
return v
196197
}
198+
199+
// raw a helper to output input string as safe HTML
200+
func raw(i string) template.HTML {
201+
return template.HTML(i)
202+
}

0 commit comments

Comments
 (0)