fix(toc): show toc for org mode headings spanning multiple lines

closes #1872
This commit is contained in:
Aditya Telange committed 2026-10-18 20:18:45 +05:30
1 parent 77ff4a25f5
commit 17bf01d323
1 file changed
+2 -2
+2 -2
View File
@@ -1,4 +1,4 @@
{{- $headers := findRE "<h[1-6].*?>(.|\n])+?</h[1-6]>" .Content -}}
{{- $headers := findRE "<h[1-6].*?>(.|\n)+?</h[1-6]>" .Content -}}
{{- $has_headers := ge (len $headers) 1 -}}
{{- if $has_headers -}}
<details class="toc" {{if (.Param "TocOpen") }} open{{ end }}>
@@ -36,7 +36,7 @@
{{- /* strip id="" to leave xyz, no way to get regex capturing groups in hugo */ -}}
{{- $cleanedID := replace (replace $id "id=\"" "") "\"" "" }}
{{- $header := replaceRE "<h[1-6].*?>((.|\n])+?)</h[1-6]>" "$1" $header -}}
{{- $header := replaceRE "<h[1-6].*?>((.|\n)+?)</h[1-6]>" "$1" $header | strings.TrimSpace -}}
{{- if ne $i 0 -}}
{{- $prevHeaderLevel := index (findRE "[1-6]" (index $headers (sub $i 1)) 1) 0 -}}