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
6
html.go
6
html.go
|
@ -908,7 +908,10 @@ func (r *HTMLRenderer) writeTOC(w io.Writer, ast *Node) {
|
||||||
if node.Type == Heading && !node.HeadingData.IsTitleblock {
|
if node.Type == Heading && !node.HeadingData.IsTitleblock {
|
||||||
inHeading = entering
|
inHeading = entering
|
||||||
if entering {
|
if entering {
|
||||||
|
if node.HeadingID == "" {
|
||||||
node.HeadingID = fmt.Sprintf("toc_%d", headingCount)
|
node.HeadingID = fmt.Sprintf("toc_%d", headingCount)
|
||||||
|
headingCount++
|
||||||
|
}
|
||||||
if node.Level == tocLevel {
|
if node.Level == tocLevel {
|
||||||
buf.WriteString("</li>\n\n<li>")
|
buf.WriteString("</li>\n\n<li>")
|
||||||
} else if node.Level < tocLevel {
|
} 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)
|
fmt.Fprintf(&buf, `<a href="#%s">`, node.HeadingID)
|
||||||
headingCount++
|
|
||||||
} else {
|
} else {
|
||||||
buf.WriteString("</a>")
|
buf.WriteString("</a>")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user