mirror of
https://github.com/russross/blackfriday.git
synced 2024-03-22 13:40:34 +08:00
Fix bug: AutoHeadingIDs being ignored
This commit is contained in:
parent
3b2b20c8cb
commit
75b4f49c4a
8
html.go
8
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("</li>\n\n<li>")
|
||||
} else if node.Level < tocLevel {
|
||||
|
@ -924,8 +927,7 @@ func (r *HTMLRenderer) writeTOC(w io.Writer, ast *Node) {
|
|||
}
|
||||
}
|
||||
|
||||
fmt.Fprintf(&buf, `<a href="#toc_%d">`, headingCount)
|
||||
headingCount++
|
||||
fmt.Fprintf(&buf, `<a href="#%s">`, node.HeadingID)
|
||||
} else {
|
||||
buf.WriteString("</a>")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user