mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-12 20:13:59 +02:00
markup/goldmark: Trim space from blockquote render hook text
Closes #13302
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
cd7dc7a372
commit
e08d9af21e
@@ -69,7 +69,7 @@ func (r *htmlRenderer) renderBlockquote(w util.BufWriter, src []byte, node ast.N
|
|||||||
return ast.WalkContinue, nil
|
return ast.WalkContinue, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
text := ctx.PopRenderedString()
|
text := strings.TrimSpace(ctx.PopRenderedString())
|
||||||
|
|
||||||
ordinal := ctx.GetAndIncrementOrdinal(ast.KindBlockquote)
|
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
|
// 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
|
// closing p tag. At some point we might want to move this to the
|
||||||
// parser.
|
// parser.
|
||||||
before, after, found := strings.Cut(strings.TrimSpace(text), "\n")
|
before, after, found := strings.Cut(text, "\n")
|
||||||
if found {
|
if found {
|
||||||
if strings.HasSuffix(before, "</p>") {
|
if strings.HasSuffix(before, "</p>") {
|
||||||
text = after
|
text = after
|
||||||
|
@@ -76,7 +76,7 @@ title: "p1"
|
|||||||
"Blockquote Alert: |<p>This is a note with some whitespace after the alert type.</p>|alert|",
|
"Blockquote Alert: |<p>This is a note with some whitespace after the alert type.</p>|alert|",
|
||||||
"Blockquote Alert: |<p>This is a tip.</p>",
|
"Blockquote Alert: |<p>This is a tip.</p>",
|
||||||
"Blockquote Alert: |<p>This is a caution with some whitespace before the alert type.</p>|alert|",
|
"Blockquote Alert: |<p>This is a caution with some whitespace before the alert type.</p>|alert|",
|
||||||
"Blockquote: |<p>A regular blockquote.</p>\n|regular|",
|
"Blockquote: |<p>A regular blockquote.</p>|regular|",
|
||||||
"Blockquote Alert Attributes: |<p>This is a tip with attributes.</p>|map[class:foo bar id:baz]|",
|
"Blockquote Alert Attributes: |<p>This is a tip with attributes.</p>|map[class:foo bar id:baz]|",
|
||||||
filepath.FromSlash("/content/p1.md:19:3"),
|
filepath.FromSlash("/content/p1.md:19:3"),
|
||||||
"Blockquote Alert Page: |<p>This is a tip with attributes.</p>|p1|p1|",
|
"Blockquote Alert Page: |<p>This is a tip with attributes.</p>|p1|p1|",
|
||||||
@@ -155,6 +155,7 @@ AlertType: {{ .AlertType }}|AlertTitle: {{ .AlertTitle }}|AlertSign: {{ .AlertSi
|
|||||||
|
|
||||||
// Issue 12913
|
// Issue 12913
|
||||||
// Issue 13119
|
// Issue 13119
|
||||||
|
// Issue 13302
|
||||||
func TestBlockquoteRenderHookTextParsing(t *testing.T) {
|
func TestBlockquoteRenderHookTextParsing(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@@ -225,6 +226,7 @@ title: home
|
|||||||
> [!sixteen] _title_
|
> [!sixteen] _title_
|
||||||
> line one
|
> line one
|
||||||
|
|
||||||
|
> seventeen
|
||||||
`
|
`
|
||||||
|
|
||||||
b := hugolib.Test(t, files)
|
b := hugolib.Test(t, files)
|
||||||
@@ -246,5 +248,6 @@ title: home
|
|||||||
"AlertType: fourteen|AlertTitle: title|Text: <p><img src=\"a.jpg\" alt=\"alt\"></p>|",
|
"AlertType: fourteen|AlertTitle: title|Text: <p><img src=\"a.jpg\" alt=\"alt\"></p>|",
|
||||||
"AlertType: fifteen|AlertTitle: <em>title</em>|Text: |",
|
"AlertType: fifteen|AlertTitle: <em>title</em>|Text: |",
|
||||||
"AlertType: sixteen|AlertTitle: <em>title</em>|Text: <p>line one</p>|",
|
"AlertType: sixteen|AlertTitle: <em>title</em>|Text: <p>line one</p>|",
|
||||||
|
"AlertType: |AlertTitle: |Text: <p>seventeen</p>|",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user