{{- /* Convert Hugo's HTML table of contents to JSON using regex substitutions */ -}} {{- /* Input: page object */ -}} {{- /* Output: JSON structure representing the table of contents */ -}} {{- $toc := .TableOfContents -}} {{- /* Remove the nav wrapper and all newlines/extra whitespace */ -}} {{- $toc = $toc | replaceRE "" "" -}} {{- $toc = $toc | replaceRE "\\n\\s*" "" -}} {{- /* Step 1: Replace