mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
a2f67152b3
commit
c837f36ab4
2 changed files with 10 additions and 2 deletions
|
@ -368,6 +368,13 @@ testContent
|
||||||
c.Assert(ok, qt.Equals, true)
|
c.Assert(ok, qt.Equals, true)
|
||||||
|
|
||||||
c.Assert(toc.TableOfContents().Identifiers, qt.DeepEquals, collections.SortedStringSlice{"_introduction", "_section_1", "_section_1_1", "_section_1_1_1", "_section_1_2", "_section_2"})
|
c.Assert(toc.TableOfContents().Identifiers, qt.DeepEquals, collections.SortedStringSlice{"_introduction", "_section_1", "_section_1_1", "_section_1_1_1", "_section_1_2", "_section_2"})
|
||||||
|
// Although "Introduction" has a level 3 markup heading, AsciiDoc treats the first heading as level 2.
|
||||||
|
c.Assert(toc.TableOfContents().HeadingsMap["_introduction"].Level, qt.Equals, 2)
|
||||||
|
c.Assert(toc.TableOfContents().HeadingsMap["_section_1"].Level, qt.Equals, 2)
|
||||||
|
c.Assert(toc.TableOfContents().HeadingsMap["_section_1_1"].Level, qt.Equals, 3)
|
||||||
|
c.Assert(toc.TableOfContents().HeadingsMap["_section_1_1_1"].Level, qt.Equals, 4)
|
||||||
|
c.Assert(toc.TableOfContents().HeadingsMap["_section_1_2"].Level, qt.Equals, 3)
|
||||||
|
c.Assert(toc.TableOfContents().HeadingsMap["_section_2"].Level, qt.Equals, 2)
|
||||||
c.Assert(string(r.Bytes()), qt.Not(qt.Contains), "<div id=\"toc\" class=\"toc\">")
|
c.Assert(string(r.Bytes()), qt.Not(qt.Contains), "<div id=\"toc\" class=\"toc\">")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -243,6 +243,7 @@ func parseTOC(doc *html.Node) *tableofcontents.Fragments {
|
||||||
toc.AddAt(&tableofcontents.Heading{
|
toc.AddAt(&tableofcontents.Heading{
|
||||||
Title: nodeContent(c),
|
Title: nodeContent(c),
|
||||||
ID: href,
|
ID: href,
|
||||||
|
Level: level + 1,
|
||||||
}, row, level)
|
}, row, level)
|
||||||
}
|
}
|
||||||
f(n.FirstChild, row, level)
|
f(n.FirstChild, row, level)
|
||||||
|
|
Loading…
Reference in a new issue