From a7d2dfc4fc1c0592964b6173a748c03d7807901f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Mon, 4 Jun 2018 18:35:54 +0300 Subject: [PATCH] Fix some issues with ToC (#8797) * Allow HTML in ToC Fixes #4793 * Extract ToC id from the header This is needed when the id is set explicitly in markdown. --- layouts/partials/templates/blocks.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/layouts/partials/templates/blocks.html b/layouts/partials/templates/blocks.html index 280aa6aa5d..765b884ac7 100644 --- a/layouts/partials/templates/blocks.html +++ b/layouts/partials/templates/blocks.html @@ -9,8 +9,10 @@ {{ $section := $.ctx.Scratch.Get "section" }} {{ $headers := findRE "(.|\n)*?" $section }} {{ range $headers }} -{{ $header := . | replaceRE "" "" | htmlUnescape }} -
  • {{ $header }}
  • +{{ $id := . | strings.TrimPrefix "

    .*" "" }} +{{ $header := . | replaceRE "" "" | htmlUnescape | safeHTML }} +
  • {{ $header }}
  • {{ end }} {{ $.ctx.Scratch.Add "sections" $section }} {{ end }}