mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
markup/tableofcontents: Return template.HTML from .Fragments.ToHTML
Closes #11545
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
d5d0f420d8
commit
1b5f78b6b7
@@ -109,7 +109,7 @@ LINE1
|
||||
|
||||
* Autolink: https://gohugo.io/
|
||||
* Strikethrough:~~Hi~~ Hello, world!
|
||||
|
||||
|
||||
## Table
|
||||
|
||||
| foo | bar |
|
||||
@@ -137,7 +137,7 @@ That's some text with a footnote.[^1]
|
||||
## Definition Lists
|
||||
|
||||
date
|
||||
: the datetime assigned to this page.
|
||||
: the datetime assigned to this page.
|
||||
|
||||
description
|
||||
: the description for the content.
|
||||
@@ -204,8 +204,8 @@ unsafe = true
|
||||
|
||||
toc, ok := b.(converter.TableOfContentsProvider)
|
||||
c.Assert(ok, qt.Equals, true)
|
||||
tocHTML := toc.TableOfContents().ToHTML(1, 2, false)
|
||||
c.Assert(tocHTML, qt.Contains, "TableOfContents")
|
||||
tocString := string(toc.TableOfContents().ToHTML(1, 2, false))
|
||||
c.Assert(tocString, qt.Contains, "TableOfContents")
|
||||
}
|
||||
|
||||
func TestConvertAutoIDAsciiOnly(t *testing.T) {
|
||||
|
@@ -62,7 +62,8 @@ And then some.
|
||||
c.Assert(err, qt.IsNil)
|
||||
b, err := conv.Convert(converter.RenderContext{Src: []byte(content), RenderTOC: true, GetRenderer: nopGetRenderer})
|
||||
c.Assert(err, qt.IsNil)
|
||||
got := b.(converter.TableOfContentsProvider).TableOfContents().ToHTML(2, 3, false)
|
||||
tocHTML := b.(converter.TableOfContentsProvider).TableOfContents().ToHTML(2, 3, false)
|
||||
got := string(tocHTML)
|
||||
c.Assert(got, qt.Equals, `<nav id="TableOfContents">
|
||||
<ul>
|
||||
<li><a href="#first-h2---now-with-typography">First h2—now with typography!</a>
|
||||
@@ -104,7 +105,8 @@ func TestEscapeToc(t *testing.T) {
|
||||
// content := ""
|
||||
b, err := safeConv.Convert(converter.RenderContext{Src: []byte(content), RenderTOC: true, GetRenderer: nopGetRenderer})
|
||||
c.Assert(err, qt.IsNil)
|
||||
got := b.(converter.TableOfContentsProvider).TableOfContents().ToHTML(1, 2, false)
|
||||
tocHTML := b.(converter.TableOfContentsProvider).TableOfContents().ToHTML(1, 2, false)
|
||||
got := string(tocHTML)
|
||||
c.Assert(got, qt.Equals, `<nav id="TableOfContents">
|
||||
<ul>
|
||||
<li><a href="#a--b--c--d">A < B & C > D</a></li>
|
||||
@@ -116,7 +118,8 @@ func TestEscapeToc(t *testing.T) {
|
||||
|
||||
b, err = unsafeConv.Convert(converter.RenderContext{Src: []byte(content), RenderTOC: true, GetRenderer: nopGetRenderer})
|
||||
c.Assert(err, qt.IsNil)
|
||||
got = b.(converter.TableOfContentsProvider).TableOfContents().ToHTML(1, 2, false)
|
||||
tocHTML = b.(converter.TableOfContentsProvider).TableOfContents().ToHTML(1, 2, false)
|
||||
got = string(tocHTML)
|
||||
c.Assert(got, qt.Equals, `<nav id="TableOfContents">
|
||||
<ul>
|
||||
<li><a href="#a--b--c--d">A < B & C > D</a></li>
|
||||
|
Reference in New Issue
Block a user