Skip to content

Commit afb6e90

Browse files
lamATnginxnginx-jack
authored andcommitted
fix: toc not rendering correctly
1 parent 8b07fe1 commit afb6e90

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed
Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1-
{{ $code := .Inner | safeHTML }}
2-
{{ $lines := split $code "\n" }}
31
<div data-mf="true" class="highlight-mf" style="display: none">
2+
{{- $code := .Inner -}}
3+
{{- $lines := split $code "\n" -}}
44
<pre class="chroma" tabindex="0">
5-
<code class="language-{{ .Type }}">
6-
{{ range $lines }}
7-
<span class="line">{{ $line := . }}{{ $parts := split $line "#" }}<span class="code">{{ index $parts 0 | safeHTML }}
8-
</span>{{ $commentPart := "" }}{{ if gt (len $parts) 1 }}<span class="comment">{{ index $parts 1 | safeHTML }}</span>{{ end }}</span>
9-
{{ end }}
5+
<code class="language-{{- .Type -}}">
6+
{{- range $lines -}}
7+
<span class="line">
8+
{{- $line := . -}}
9+
{{- $parts := split $line "#" -}}
10+
<span class="code">
11+
{{- index $parts 0 -}}
12+
</span>
13+
{{- $commentPart := "" -}}
14+
{{- if gt (len $parts) 1 -}}
15+
<span class="comment">
16+
{{- index $parts 1 -}}
17+
</span>
18+
{{- end -}}
19+
</span>
20+
{{- end -}}
1021
</code>
1122
</pre>
1223
</div>
13-
14-
{{ $result := transform.HighlightCodeBlock . }}
15-
{{ $result.Wrapped }}
16-
17-
<!-- ABSOLUTELY DO NOT CHANGE THIS ORDER -->
24+
{{- $result := transform.HighlightCodeBlock . -}}
25+
{{- $result.Wrapped -}}
26+
{{- "" -}}

layouts/partials/toc.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<nav class="bd-links" aria-label="Main navigation">
22
<div class="bd-toc-item active">
33
<h3 class="bd-toc-link">What's on This Page</h3>
4-
{{ if .Params.catalogType }}
5-
{{ partial "catalog-toc" . }}
6-
{{ else }}
7-
{{ with .TableOfContents }}
8-
{{ . }}
9-
{{ end }}
4+
{{- if .Params.catalogType -}}
5+
{{- partial "catalog-toc" . -}}
6+
{{- else -}}
7+
{{- with .TableOfContents -}}
8+
{{- . -}}
9+
{{- end -}}
1010
{{ end }}
1111
</div>
1212
</nav>

0 commit comments

Comments
 (0)