markup/tableofcontents: Return template.HTML from .Fragments.ToHTML

Closes #11545
This commit is contained in:
Joe Mooring
2023-10-08 16:59:36 -07:00
committed by Bjørn Erik Pedersen
parent d5d0f420d8
commit 1b5f78b6b7
4 changed files with 21 additions and 17 deletions

View File

@@ -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) {

View File

@@ -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&mdash;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 &lt; B &amp; C &gt; 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 &lt; B &amp; C &gt; D</a></li>