{{ $headings := findRE "(.|\n])+?" .Content }} {{ if ge (len $headings) 2 }}

Table of contents

    {{ range $headings }}
  1. {{ $id := findRE "id=\".*\"" . }} {{ $id = index $id 0 }} {{ $id = strings.TrimPrefix "id=\"" $id }} {{ $id = strings.TrimSuffix "\"" $id }} {{ . | htmlUnescape | plainify }}
  2. {{ end }}
{{ end }}