mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
caa90e6a12
commit
bef9214e11
2 changed files with 36 additions and 14 deletions
|
@ -75,20 +75,6 @@ func (r *htmlRenderer) renderBlockquote(w util.BufWriter, src []byte, node ast.N
|
||||||
text := ctx.Buffer.Bytes()[pos:]
|
text := ctx.Buffer.Bytes()[pos:]
|
||||||
ctx.Buffer.Truncate(pos)
|
ctx.Buffer.Truncate(pos)
|
||||||
|
|
||||||
// Extract a source sample to use for position information.
|
|
||||||
nn := n.FirstChild()
|
|
||||||
var start, stop int
|
|
||||||
for i := 0; i < nn.Lines().Len() && i < 2; i++ {
|
|
||||||
line := nn.Lines().At(i)
|
|
||||||
if i == 0 {
|
|
||||||
start = line.Start
|
|
||||||
}
|
|
||||||
stop = line.Stop
|
|
||||||
}
|
|
||||||
|
|
||||||
// We do not mutate the source, so this is safe.
|
|
||||||
sourceRef := src[start:stop]
|
|
||||||
|
|
||||||
ordinal := ctx.GetAndIncrementOrdinal(ast.KindBlockquote)
|
ordinal := ctx.GetAndIncrementOrdinal(ast.KindBlockquote)
|
||||||
|
|
||||||
texts := string(text)
|
texts := string(text)
|
||||||
|
@ -110,6 +96,22 @@ func (r *htmlRenderer) renderBlockquote(w util.BufWriter, src []byte, node ast.N
|
||||||
texts = "<p>" + texts[strings.Index(texts, "\n")+1:]
|
texts = "<p>" + texts[strings.Index(texts, "\n")+1:]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var sourceRef []byte
|
||||||
|
|
||||||
|
// Extract a source sample to use for position information.
|
||||||
|
if nn := n.FirstChild(); nn != nil {
|
||||||
|
var start, stop int
|
||||||
|
for i := 0; i < nn.Lines().Len() && i < 2; i++ {
|
||||||
|
line := nn.Lines().At(i)
|
||||||
|
if i == 0 {
|
||||||
|
start = line.Start
|
||||||
|
}
|
||||||
|
stop = line.Stop
|
||||||
|
}
|
||||||
|
// We do not mutate the source, so this is safe.
|
||||||
|
sourceRef = src[start:stop]
|
||||||
|
}
|
||||||
|
|
||||||
bqctx := &blockquoteContext{
|
bqctx := &blockquoteContext{
|
||||||
page: ctx.DocumentContext().Document,
|
page: ctx.DocumentContext().Document,
|
||||||
pageInner: r.getPageInner(ctx),
|
pageInner: r.getPageInner(ctx),
|
||||||
|
|
|
@ -81,3 +81,23 @@ title: "p1"
|
||||||
"Blockquote Alert Page: |<p>This is a tip with attributes.</p>\n|p1|p1|",
|
"Blockquote Alert Page: |<p>This is a tip with attributes.</p>\n|p1|p1|",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBlockquoteEmptyIssue12756(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
files := `
|
||||||
|
-- hugo.toml --
|
||||||
|
-- content/p1.md --
|
||||||
|
---
|
||||||
|
title: "p1"
|
||||||
|
---
|
||||||
|
|
||||||
|
>
|
||||||
|
-- layouts/_default/single.html --
|
||||||
|
Content: {{ .Content }}
|
||||||
|
|
||||||
|
`
|
||||||
|
|
||||||
|
b := hugolib.Test(t, files)
|
||||||
|
b.AssertFileContent("public/p1/index.html", "Content: <blockquote>\n</blockquote>\n")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue