From 1b5f78b6b7335b02b6207a637498c4c8817999d1 Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Sun, 8 Oct 2023 16:59:36 -0700 Subject: [PATCH] markup/tableofcontents: Return template.HTML from .Fragments.ToHTML Closes #11545 --- markup/goldmark/convert_test.go | 8 ++++---- markup/goldmark/toc_test.go | 9 ++++++--- markup/tableofcontents/tableofcontents.go | 5 +++-- markup/tableofcontents/tableofcontents_test.go | 16 ++++++++-------- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/markup/goldmark/convert_test.go b/markup/goldmark/convert_test.go index ed791448b..6d73b301f 100644 --- a/markup/goldmark/convert_test.go +++ b/markup/goldmark/convert_test.go @@ -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) { diff --git a/markup/goldmark/toc_test.go b/markup/goldmark/toc_test.go index f7f7bb7a0..1b846877b 100644 --- a/markup/goldmark/toc_test.go +++ b/markup/goldmark/toc_test.go @@ -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, `