From 75b4f49c4aa598adba8e619bcf133f09dceea689 Mon Sep 17 00:00:00 2001 From: Almog Baku Date: Fri, 13 Mar 2020 16:03:05 +0200 Subject: [PATCH] Fix bug: AutoHeadingIDs being ignored --- html.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/html.go b/html.go index 63b7435..7db102f 100644 --- a/html.go +++ b/html.go @@ -908,7 +908,10 @@ func (r *HTMLRenderer) writeTOC(w io.Writer, ast *Node) { if node.Type == Heading && !node.HeadingData.IsTitleblock { inHeading = entering if entering { - node.HeadingID = fmt.Sprintf("toc_%d", headingCount) + if node.HeadingID == "" { + node.HeadingID = fmt.Sprintf("toc_%d", headingCount) + headingCount++ + } if node.Level == tocLevel { buf.WriteString("\n\n
  • ") } else if node.Level < tocLevel { @@ -924,8 +927,7 @@ func (r *HTMLRenderer) writeTOC(w io.Writer, ast *Node) { } } - fmt.Fprintf(&buf, ``, headingCount) - headingCount++ + fmt.Fprintf(&buf, ``, node.HeadingID) } else { buf.WriteString("") }