Backtestshugorun-20261013-011256#14044

Issue #14044 Merged fix PR #15353 Run 13 Oct 2026 · run-20261013-011256 gohugoio/hugo

Automatic summary may generate invalid HTML with blockquotes and lists

Better

Our patch was judged better than the merged fix.

In this judgment, Patch A = our agent, Patch B = the merged fix.

Both patches move the summary cut-off forward when it falls inside an open element, which fixes the reported blockquote and list leak. They differ in which elements trigger that expansion.

Patch B balances every open element, including generic wrapper `div`s. AsciiDoc output nests content in `sect1`/`sectionbody` divs, Org mode in `outline-*` divs, and Markdown authors often wrap a whole post in a raw `<div class="post">`. In each of those cases Patch B would extend the summary to the end of the section or even the whole document. That is a substantial behavioral regression: summaries could silently become the entire content.

Patch A limits expansion to the element types the issue is about (`blockquote`, `ul`, `ol`, `dl`, `table`), anchored to the outermost such element open at the cut point. It also absorbs directly-following end tags such as the AsciiDoc `quoteblock` wrapper div, and keeps the original cut if the element is never closed. Its tests explicitly cover the regression risks Patch B misses:
- Org outline wrappers and a plain div wrapper are not expanded.
- Nested AsciiDoc sections are handled.
- Wrapped reStructuredText output (the `<div class="document">` case) is handled.
- Nested blockquotes, lists with void elements, and unclosed blockquotes are handled.

Patch A also adds an integration test that reproduces the issue end to end.

Patch A uses the robust `x/net/html` tokenizer. Patch B hand-rolls a scanner, which adds surface for edge-case bugs. Patch B also rewrites the existing benchmark, dropping its correctness assertions and switching from `b.Loop` to `b.N`. That is unrelated churn that weakens existing checks.

Overall Patch A is more correct and targeted, and better tested.

The judge saw only the two patches, labelled A and B in random order, with issue links and version numbers removed. The reasoning above is shown verbatim.

Solve

1h 31m

Wall-clock time in the container

Full test suite

No new failures

2,242 passed · 95 skipped · 2,344 total

Contamination audit

Clean

No sign the agent saw the real fix

Patch size

168vs 226 merged

Changed lines, ours vs merged

<!--
Please do not use the issue queue for questions or troubleshooting. Unless you are certain that your issue is a software defect, use the forum:

https://discourse.gohugo.io
-->

<!-- Please answer these questions before submitting your issue. Thanks! -->

What version of Hugo are you using (hugo version)?

<pre>
$ hugo version
hugo v0.151.0+extended+withdeploy darwin/arm64 BuildDate=2025-10-02T13:30:36Z VendorInfo=brew
</pre>

Does this issue reproduce with the latest release?

Yes

Issue

Using a blockquote that extends past the .Summary cutoff causes the content below {{ .Summary }} to be treated as part of the blockquote until the end of the parent tag. Reproduction repo

<img width="848" height="652" alt="Image" src="https://github.com/user-attachments/assets/212f747c-af3c-4af5-89fe-78fe9dc04ebd" />

Hugo's .Summary may lead to blockquote end tag be below cutoff point

Explanation

In most modern browsers this html code will be parsed and rendered without errors

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
  <main>
    <blockquote>
      <p>1</p>
  </main>
</body>
</html>

Leading to shown in browser as a source

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
  <main>
    <blockquote>
      <p>1</p>
      <!-- This blockquote end tag was automatically inserted -->
    </blockquote>
  </main>
</body>
</html>

This is due to these parsing rules

An end tag whose tag name is one of: "address", "article", "aside", "blockquote", "button", "center", "details", "dialog", "dir", "div", "dl", "fieldset", "figcaption", "figure", "footer", "header", "hgroup", "listing", "main", "menu", "nav", "ol", "pre", "search", "section", "select", "summary", "ul"

If the stack of open elements does not have an element in scope that is an HTML element with the same tag name as that of the token, then this is a parse error; ignore the token.

Otherwise, run these steps:

Generate implied end tags.

If the current node is not an HTML element with the same tag name as that of the token, then this is a parse error.

Pop elements from the stack of open elements until an HTML element with the same tag name as the token has been popped from the stack.

To Discuss

I think the best case scenario is for .Summary to handle generation of implied tags. But I am not sure how to do that myself.

For now I plan to provide a PR with fixes for a theme and docs, to avoid confusion and errors

The two patches

Our patch+167 −1
resources/page/page_markup.goindex 8f58fc2ab..487ec9841 100644@@ -25,6 +25,7 @@ import ( 	"github.com/gohugoio/hugo/markup/tableofcontents" 	"github.com/gohugoio/hugo/media" 	"github.com/gohugoio/hugo/tpl"+	"golang.org/x/net/html" )  type Content interface {@@ -236,7 +237,7 @@ func ExtractSummaryFromHTML(mt media.Type, input string, numWords int, isCJK boo 		if count >= numWords { 			result.SummaryLowHigh = types.LowHigh[string]{ 				Low:  result.WrapperStart.High,-				High: j + closingIndex + len(ptag.tagName) + 3,+				High: expandToEnclosingElementEnd(input, result.WrapperStart.High, j+closingIndex+len(ptag.tagName)+3, high), 			} 			return 		}@@ -253,6 +254,106 @@ func ExtractSummaryFromHTML(mt media.Type, input string, numWords int, isCJK boo 	return } +// expandToEnclosingElementEnd returns the position in s of the end of the+// outermost blockquote, list or table that is still open at pos when parsing s from start,+// including any end tags that directly follow it (e.g. an AsciiDoc quoteblock wrapper).+// Other open elements (e.g. section wrappers) do not trigger an expansion.+// It returns pos if no such element is open at pos, or if it is not closed before limit.+// See issue 14044.+func expandToEnclosingElementEnd(s string, start, pos, limit int) int {+	var stack []string++	// popTo pops the stack up to and including the last element with the given name, if present.+	popTo := func(name string) {+		for i := len(stack) - 1; i >= 0; i-- {+			if stack[i] == name {+				stack = stack[:i]+				return+			}+		}+	}++	z := html.NewTokenizer(strings.NewReader(s[start:limit]))+	offset := start+	depth := -1 // The stack depth to unwind to, set once we reach pos.+	end := -1   // The end of the expanded element, set once it is closed.+	for {+		tt := z.Next()+		if tt == html.ErrorToken {+			// io.EOF.+			if end != -1 {+				return end+			}+			// The element is not closed within limit.+			return pos+		}+		offset += len(z.Raw())++		if end != -1 {+			// Absorb whitespace and end tags directly following the element.+			switch tt {+			case html.TextToken:+				if strings.TrimSpace(string(z.Raw())) == "" {+					continue+				}+			case html.EndTagToken:+				name, _ := z.TagName()+				n := len(stack)+				popTo(string(name))+				if len(stack) < n {+					end = offset+					continue+				}+			}+			return end+		}++		switch tt {+		case html.StartTagToken:+			name, _ := z.TagName()+			if !isVoidElement(string(name)) {+				stack = append(stack, string(name))+			}+		case html.EndTagToken:+			name, _ := z.TagName()+			popTo(string(name))+		}++		if depth == -1 && offset >= pos {+			for i, name := range stack {+				if isSummaryBreakingElement(name) {+					depth = i+					break+				}+			}+			if depth == -1 {+				return pos+			}+		}++		if depth != -1 && len(stack) <= depth {+			end = offset+		}+	}+}++// isSummaryBreakingElement reports whether the summary should not end inside the element with the given name.+func isSummaryBreakingElement(name string) bool {+	switch name {+	case "blockquote", "dl", "ol", "table", "ul":+		return true+	}+	return false+}++func isVoidElement(name string) bool {+	switch name {+	case "area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr":+		return true+	}+	return false+}+ // ExtractSummaryFromHTMLWithDivider extracts a summary from the given HTML content with // a manual summary divider. func ExtractSummaryFromHTMLWithDivider(mt media.Type, input, divider string) (result HtmlSummary) {resources/page/page_markup_integration_test.goindex 412850b3a..3d85b15dd 100644@@ -387,6 +387,57 @@ one two three <!--more--> 	b.AssertFileContent("public/p4/index.html", `Title: p4|Summary: <p>one two three</p>|Truncated: false|`) } +func TestIssue14044(t *testing.T) {+	t.Parallel()++	files := `+-- hugo.toml --+disableKinds = ['home','rss','section','sitemap','taxonomy','term']+summaryLength = 2+-- layouts/all.html --+Summary: {{ .Summary }}|Truncated: {{ .Truncated }}|ContentWithoutSummary: {{ .ContentWithoutSummary }}|+-- content/blockquote.md --+---+title: blockquote+---+> one+>+> two+>+> three++four+-- content/list.md --+---+title: list+---+1. one++   two+2. three++four+-- content/divider.md --+---+title: divider+---+> one+>+> <!--more-->+>+> two++- three+- <!--more-->+- four+`+	b := hugolib.Test(t, files)++	b.AssertFileContent("public/blockquote/index.html", "Summary: <blockquote>\n<p>one</p>\n<p>two</p>\n<p>three</p>\n</blockquote>|Truncated: true|ContentWithoutSummary: <p>four</p>|")+	b.AssertFileContent("public/list/index.html", "Summary: <ol>\n<li>\n<p>one</p>\n<p>two</p>\n</li>\n<li>\n<p>three</p>\n</li>\n</ol>|Truncated: true|ContentWithoutSummary: <p>four</p>|")+	b.AssertFileContent("public/divider/index.html", "Summary: <blockquote>\n<p>one</p>\n</blockquote>|Truncated: true|")+}+ func TestIssue13968(t *testing.T) { 	t.Parallel() resources/page/page_markup_test.goindex fc1102434..567086651 100644@@ -40,6 +40,20 @@ func TestExtractSummaryFromHTML(t *testing.T) { 		{media.Builtin.MarkdownType, "<p>First paragraph</p><p>Second paragraph</p><p>Third paragraph</p>", false, 3, "<p>First paragraph</p><p>Second paragraph</p>", "<p>Third paragraph</p>"}, 		{media.Builtin.AsciiDocType, "<div><p>First paragraph</p></div><div><p>Second paragraph</p></div>", false, 2, "<div><p>First paragraph</p></div>", "<div><p>Second paragraph</p></div>"}, 		{media.Builtin.MarkdownType, "<p>这是中文,全中文</p><p>a这是中文,全中文</p>", true, 5, "<p>这是中文,全中文</p>", "<p>a这是中文,全中文</p>"},+		// Issue 14044.+		{media.Builtin.MarkdownType, "<blockquote>\n<p>First paragraph</p>\n<p>Second paragraph</p>\n</blockquote>\n<p>Third paragraph</p>", false, 2, "<blockquote>\n<p>First paragraph</p>\n<p>Second paragraph</p>\n</blockquote>", "<p>Third paragraph</p>"},+		{media.Builtin.MarkdownType, "<blockquote>\n<blockquote>\n<p>First paragraph</p>\n</blockquote>\n<p>Second paragraph</p>\n</blockquote>\n<p>Third paragraph</p>", false, 2, "<blockquote>\n<blockquote>\n<p>First paragraph</p>\n</blockquote>\n<p>Second paragraph</p>\n</blockquote>", "<p>Third paragraph</p>"},+		{media.Builtin.MarkdownType, "<ul>\n<li>\n<p>First item</p>\n</li>\n<li>\n<p>Second item</p>\n</li>\n</ul>\n<p>Third paragraph</p>", false, 2, "<ul>\n<li>\n<p>First item</p>\n</li>\n<li>\n<p>Second item</p>\n</li>\n</ul>", "<p>Third paragraph</p>"},+		{media.Builtin.MarkdownType, "<ol>\n<li>\n<p>First <img src=\"a.jpg\"> item</p>\n<ul>\n<li><p>Nested item</p></li>\n</ul>\n</li>\n</ol>\n<p>Third paragraph</p>", false, 2, "<ol>\n<li>\n<p>First <img src=\"a.jpg\"> item</p>\n<ul>\n<li><p>Nested item</p></li>\n</ul>\n</li>\n</ol>", "<p>Third paragraph</p>"},+		{media.Builtin.MarkdownType, "<p>First paragraph</p>\n<blockquote>\n<p>Second paragraph</p>\n</blockquote>", false, 2, "<p>First paragraph</p>", "<blockquote>\n<p>Second paragraph</p>\n</blockquote>"},+		{media.Builtin.ReStructuredTextType, "<div class=\"document\"><blockquote><p>First paragraph</p><p>Second paragraph</p></blockquote><p>Third paragraph</p></div>", false, 2, `<div class="document"><blockquote><p>First paragraph</p><p>Second paragraph</p></blockquote></div>`, "<div class=\"document\"><p>Third paragraph</p></div>"},+		{media.Builtin.AsciiDocType, "<div class=\"quoteblock\"><blockquote><div class=\"paragraph\"><p>First paragraph</p></div><div class=\"paragraph\"><p>Second paragraph</p></div></blockquote></div><div class=\"paragraph\"><p>Third paragraph</p></div>", false, 2, "<div class=\"quoteblock\"><blockquote><div class=\"paragraph\"><p>First paragraph</p></div><div class=\"paragraph\"><p>Second paragraph</p></div></blockquote></div>", "<div class=\"paragraph\"><p>Third paragraph</p></div>"},+		{media.Builtin.AsciiDocType, "<div class=\"sect1\"><h2>A</h2><div class=\"sectionbody\"><div class=\"quoteblock\"><blockquote><div class=\"paragraph\"><p>First paragraph</p></div><div class=\"paragraph\"><p>Second paragraph</p></div></blockquote></div><div class=\"paragraph\"><p>Third paragraph</p></div></div></div>", false, 2, "<div class=\"sect1\"><h2>A</h2><div class=\"sectionbody\"><div class=\"quoteblock\"><blockquote><div class=\"paragraph\"><p>First paragraph</p></div><div class=\"paragraph\"><p>Second paragraph</p></div></blockquote></div>", "<div class=\"paragraph\"><p>Third paragraph</p></div></div></div>"},+		// Section wrappers alone do not expand the summary to the whole section.+		{media.Builtin.EmacsOrgModeType, "<div class=\"outline-2\">\n<h2>A</h2>\n<div class=\"outline-text-2\">\n<p>First paragraph</p>\n<p>Second paragraph</p>\n</div>\n</div>", false, 2, "<div class=\"outline-2\">\n<h2>A</h2>\n<div class=\"outline-text-2\">\n<p>First paragraph</p>", "<p>Second paragraph</p>\n</div>\n</div>"},+		{media.Builtin.MarkdownType, "<div class=\"post\">\n<p>First paragraph</p>\n<p>Second paragraph</p>\n</div>", false, 2, "<div class=\"post\">\n<p>First paragraph</p>", "<p>Second paragraph</p>\n</div>"},+		// Unclosed elements, keep the original cut.+		{media.Builtin.MarkdownType, "<blockquote>\n<p>First paragraph</p>\n<p>Second paragraph</p>", false, 2, "<blockquote>\n<p>First paragraph</p>", "<p>Second paragraph</p>"}, 	}  	for i, test := range tests { 
Merged fix · PR #15353+210 −16
hugolib/page_test.goindex a50ff316b..88a6b22f3 100644@@ -788,6 +788,36 @@ Content: {{ .Content }}| 		"Content: <p>This is <strong>summary</strong>.") } +// See issue 14044.+func TestSummaryAutoBalancesContainerTags(t *testing.T) {+	t.Parallel()++	files := `+-- hugo.toml --+disableKinds = ['home','rss','section','sitemap','taxonomy','term']+summaryLength = 1+-- content/p1.md --+---+title: p1+---+> foo+-- content/p2.md --+---+title: p2+---+- item 1 line 1++  item 1 line 2+-- layouts/page.html --+|{{ .Summary }}|+`++	b := Test(t, files)++	b.AssertFileContent("public/p1/index.html", "|<blockquote>\n<p>foo</p>\n</blockquote>|")+	b.AssertFileContent("public/p2/index.html", "|<ul>\n<li>\n<p>item 1 line 1</p>\n<p>item 1 line 2</p>\n</li>\n</ul>|")+}+ // #2973 func TestSummaryWithHTMLTagsOnNextLine(t *testing.T) { 	htesting.SkipSlowTestUnlessCI(t)resources/page/page_markup.goindex 8f58fc2ab..572822b0b 100644@@ -234,9 +234,11 @@ func ExtractSummaryFromHTML(mt media.Type, input string, numWords int, isCJK boo 		}  		if count >= numWords {+			summaryHigh := j + closingIndex + len(ptag.tagName) + 3+			summaryHigh = expandSummaryHighToBalancedHTML(input, result.WrapperStart.High, summaryHigh, high) 			result.SummaryLowHigh = types.LowHigh[string]{ 				Low:  result.WrapperStart.High,-				High: j + closingIndex + len(ptag.tagName) + 3,+				High: summaryHigh, 			} 			return 		}@@ -253,6 +255,167 @@ func ExtractSummaryFromHTML(mt media.Type, input string, numWords int, isCJK boo 	return } +// expandSummaryHighToBalancedHTML moves high forward until every element+// opened in input[low:high] is closed, so the summary does not end inside+// e.g. a blockquote or list item.+func expandSummaryHighToBalancedHTML(input string, low, high, maxHigh int) int {+	if low >= high || high >= maxHigh {+		return high+	}++	var buf [16]string+	stack := buf[:0]+	sc := htmlTagScanner{s: input, pos: low}++	for {+		name, end, ok := sc.next(high)+		if !ok {+			break+		}+		stack = pushOrPopHTMLStack(stack, name, end)+	}++	if len(stack) == 0 {+		return high+	}++	for {+		name, end, ok := sc.next(maxHigh)+		if !ok {+			return high+		}+		stack = pushOrPopHTMLStack(stack, name, end)+		if len(stack) == 0 {+			return sc.pos+		}+	}+}++func pushOrPopHTMLStack(stack []string, name string, end bool) []string {+	if end {+		for i := len(stack) - 1; i >= 0; i-- {+			if stack[i] == name {+				return stack[:i]+			}+		}+		return stack+	}+	if isVoidHTMLElement(name) {+		return stack+	}+	return append(stack, name)+}++// htmlTagScanner is a minimal, allocation-free scanner for start and end tags.+// It skips comments, quoted attribute values and raw text elements.+type htmlTagScanner struct {+	s   string+	pos int+}++// next returns the lowercased name of the next tag before limit and+// whether it is an end tag. ok is false when no more tags are found.+func (sc *htmlTagScanner) next(limit int) (name string, end, ok bool) {+	for {+		i := strings.IndexByte(sc.s[sc.pos:limit], '<')+		if i == -1 {+			sc.pos = limit+			return "", false, false+		}+		sc.pos += i + 1+		if sc.pos >= limit {+			return "", false, false+		}++		end = false+		switch c := sc.s[sc.pos]; c {+		case '!', '?':+			if strings.HasPrefix(sc.s[sc.pos:limit], "!--") {+				sc.skipPast(limit, "-->")+			} else {+				sc.skipPast(limit, ">")+			}+			continue+		case '/':+			end = true+			sc.pos+++		}++		start := sc.pos+		for sc.pos < limit && isHTMLTagNameByte(sc.s[sc.pos]) {+			sc.pos+++		}+		if sc.pos == start {+			continue+		}+		name = strings.ToLower(sc.s[start:sc.pos])++		selfClosing := false+		for sc.pos < limit {+			c := sc.s[sc.pos]+			sc.pos+++			switch c {+			case '"', '\'':+				sc.skipPast(limit, string(c))+			case '/':+				selfClosing = true+			case '>':+				if selfClosing {+					continue+				}+				if !end && isRawTextHTMLElement(name) {+					sc.skipPastEndTag(limit, name)+				}+				return name, end, true+			default:+				selfClosing = false+			}+		}+		return name, end, true+	}+}++func (sc *htmlTagScanner) skipPast(limit int, sep string) {+	if i := strings.Index(sc.s[sc.pos:limit], sep); i == -1 {+		sc.pos = limit+	} else {+		sc.pos += i + len(sep)+	}+}++func (sc *htmlTagScanner) skipPastEndTag(limit int, name string) {+	for {+		sc.skipPast(limit, "</")+		if sc.pos >= limit {+			return+		}+		if rest := sc.s[sc.pos:limit]; len(rest) > len(name) && strings.EqualFold(rest[:len(name)], name) && !isHTMLTagNameByte(rest[len(name)]) {+			sc.pos -= 2+			return+		}+	}+}++func isHTMLTagNameByte(c byte) bool {+	return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '-'+}++func isRawTextHTMLElement(name string) bool {+	switch name {+	case "script", "style", "textarea", "title", "iframe", "xmp", "noembed", "noframes":+		return true+	}+	return false+}++func isVoidHTMLElement(name string) bool {+	switch name {+	case "area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "source", "track", "wbr":+		return true+	}+	return false+}+ // ExtractSummaryFromHTMLWithDivider extracts a summary from the given HTML content with // a manual summary divider. func ExtractSummaryFromHTMLWithDivider(mt media.Type, input, divider string) (result HtmlSummary) {resources/page/page_markup_test.goindex fc1102434..ee9fb1bbe 100644@@ -38,6 +38,14 @@ func TestExtractSummaryFromHTML(t *testing.T) { 		{media.Builtin.MarkdownType, "<p>First paragraph</p>", false, 10, "<p>First paragraph</p>", ""}, 		{media.Builtin.MarkdownType, "<p>First paragraph</p><p>Second paragraph</p>", false, 2, "<p>First paragraph</p>", "<p>Second paragraph</p>"}, 		{media.Builtin.MarkdownType, "<p>First paragraph</p><p>Second paragraph</p><p>Third paragraph</p>", false, 3, "<p>First paragraph</p><p>Second paragraph</p>", "<p>Third paragraph</p>"},+		{media.Builtin.MarkdownType, "<blockquote>\n<p>foo</p>\n</blockquote>\n<p>bar</p>", false, 1, "<blockquote>\n<p>foo</p>\n</blockquote>", "<p>bar</p>"},+		{media.Builtin.MarkdownType, "<ul>\n<li>\n<p>item 1 line 1</p>\n<p>item 1 line 2</p>\n</li>\n</ul>\n<p>bar</p>", false, 1, "<ul>\n<li>\n<p>item 1 line 1</p>\n<p>item 1 line 2</p>\n</li>\n</ul>", "<p>bar</p>"},+		{media.Builtin.HTMLType, "<div><p>foo</p></div><p>bar</p>", false, 1, "<div><p>foo</p></div>", "<p>bar</p>"},+		{media.Builtin.HTMLType, "<DIV><p>foo</p></DIV><p>bar</p>", false, 1, "<DIV><p>foo</p></DIV>", "<p>bar</p>"},+		{media.Builtin.HTMLType, "<div><!-- <span> --><p>foo</p></div><p>bar</p>", false, 1, "<div><!-- <span> --><p>foo</p></div>", "<p>bar</p>"},+		{media.Builtin.HTMLType, `<div><p title="a>b"><img src="x"/>foo</p></div><p>bar</p>`, false, 1, `<div><p title="a>b"><img src="x"/>foo</p></div>`, "<p>bar</p>"},+		{media.Builtin.HTMLType, "<div><script>var a = '<div>';</script><p>foo</p></div><p>bar</p>", false, 1, "<div><script>var a = '<div>';</script><p>foo</p></div>", "<p>bar</p>"},+		{media.Builtin.HTMLType, "<div><p>foo</p><p>bar</p>", false, 1, "<div><p>foo</p>", "<p>bar</p>"}, 		{media.Builtin.AsciiDocType, "<div><p>First paragraph</p></div><div><p>Second paragraph</p></div>", false, 2, "<div><p>First paragraph</p></div>", "<div><p>Second paragraph</p></div>"}, 		{media.Builtin.MarkdownType, "<p>这是中文,全中文</p><p>a这是中文,全中文</p>", true, 5, "<p>这是中文,全中文</p>", "<p>a这是中文,全中文</p>"}, 	}@@ -172,25 +180,18 @@ func TestIsProbablyHTMLToken(t *testing.T) { }  func BenchmarkSummaryFromHTML(b *testing.B) {--	input := "<p>First paragraph</p><p>Second paragraph</p>"--	for b.Loop() {-		summary := ExtractSummaryFromHTML(media.Builtin.MarkdownType, input, 2, false)-		if s := summary.Content(); s != input {-			b.Fatalf("unexpected content: %q", s)-		}-		if s := summary.ContentWithoutSummary(); s != "<p>Second paragraph</p>" {-			b.Fatalf("unexpected content without summary: %q", s)-		}-		if s := summary.Summary(); s != "<p>First paragraph</p>" {-			b.Fatalf("unexpected summary: %q", s)-		}+	run := func(name, input string) {+		b.Run(name, func(b *testing.B) {+			for i := 0; i < b.N; i++ {+				_ = ExtractSummaryFromHTML(media.Builtin.MarkdownType, input, 2, false)+			}+		}) 	}+	run("basic", "<p>First paragraph</p><p>Second paragraph</p>")+	run("list", "<ul>\n<li>\n<p>item 1 line 1</p>\n<p>item 1 line 2</p>\n</li>\n</ul>\n<p>bar</p>") }  func BenchmarkSummaryFromHTMLWithDivider(b *testing.B) {- 	input := "<p>First paragraph</p><p>FOOO</p><p>Second paragraph</p>"  	for b.Loop() {