From e08d9af21e9a29054c98c9a164fce2a0e8033fcf Mon Sep 17 00:00:00 2001
From: Joe Mooring
Date: Fri, 24 Jan 2025 09:47:45 -0800
Subject: [PATCH] markup/goldmark: Trim space from blockquote render hook text
Closes #13302
---
markup/goldmark/blockquotes/blockquotes.go | 4 ++--
markup/goldmark/blockquotes/blockquotes_integration_test.go | 5 ++++-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/markup/goldmark/blockquotes/blockquotes.go b/markup/goldmark/blockquotes/blockquotes.go
index 064200d5e..539cd1875 100644
--- a/markup/goldmark/blockquotes/blockquotes.go
+++ b/markup/goldmark/blockquotes/blockquotes.go
@@ -69,7 +69,7 @@ func (r *htmlRenderer) renderBlockquote(w util.BufWriter, src []byte, node ast.N
return ast.WalkContinue, nil
}
- text := ctx.PopRenderedString()
+ text := strings.TrimSpace(ctx.PopRenderedString())
ordinal := ctx.GetAndIncrementOrdinal(ast.KindBlockquote)
@@ -90,7 +90,7 @@ func (r *htmlRenderer) renderBlockquote(w util.BufWriter, src []byte, node ast.N
// tag if the first line of the blockquote content does not have a
// closing p tag. At some point we might want to move this to the
// parser.
- before, after, found := strings.Cut(strings.TrimSpace(text), "\n")
+ before, after, found := strings.Cut(text, "\n")
if found {
if strings.HasSuffix(before, "
") {
text = after
diff --git a/markup/goldmark/blockquotes/blockquotes_integration_test.go b/markup/goldmark/blockquotes/blockquotes_integration_test.go
index 93fe5b27d..6f7914d07 100644
--- a/markup/goldmark/blockquotes/blockquotes_integration_test.go
+++ b/markup/goldmark/blockquotes/blockquotes_integration_test.go
@@ -76,7 +76,7 @@ title: "p1"
"Blockquote Alert: |This is a note with some whitespace after the alert type.
|alert|",
"Blockquote Alert: |This is a tip.
",
"Blockquote Alert: |This is a caution with some whitespace before the alert type.
|alert|",
- "Blockquote: |A regular blockquote.
\n|regular|",
+ "Blockquote: |A regular blockquote.
|regular|",
"Blockquote Alert Attributes: |This is a tip with attributes.
|map[class:foo bar id:baz]|",
filepath.FromSlash("/content/p1.md:19:3"),
"Blockquote Alert Page: |This is a tip with attributes.
|p1|p1|",
@@ -155,6 +155,7 @@ AlertType: {{ .AlertType }}|AlertTitle: {{ .AlertTitle }}|AlertSign: {{ .AlertSi
// Issue 12913
// Issue 13119
+// Issue 13302
func TestBlockquoteRenderHookTextParsing(t *testing.T) {
t.Parallel()
@@ -225,6 +226,7 @@ title: home
> [!sixteen] _title_
> line one
+> seventeen
`
b := hugolib.Test(t, files)
@@ -246,5 +248,6 @@ title: home
"AlertType: fourteen|AlertTitle: title|Text: 
|",
"AlertType: fifteen|AlertTitle: title|Text: |",
"AlertType: sixteen|AlertTitle: title|Text: line one
|",
+ "AlertType: |AlertTitle: |Text: seventeen
|",
)
}