summaryrefslogtreecommitdiffhomepage
path: root/parser
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2018-11-05 13:30:16 +0100
committerBjørn Erik Pedersen <[email protected]>2018-11-05 14:14:28 +0100
commitd16a7a33ff1f22b9fa357189a901a4f1de4e65e7 (patch)
tree3860dd6ec35d7a22f157dc000d07fa2977e4866c /parser
parent5b1edd281a493bdb27af4dc3c8fae7e10dd54830 (diff)
downloadhugo-d16a7a33ff1f22b9fa357189a901a4f1de4e65e7.tar.gz
hugo-d16a7a33ff1f22b9fa357189a901a4f1de4e65e7.zip
Fix shortcode directly following a shortcode delimiter
Fixes #5402
Diffstat (limited to 'parser')
-rw-r--r--parser/pageparser/pagelexer.go3
-rw-r--r--parser/pageparser/pageparser_intro_test.go3
2 files changed, 6 insertions, 0 deletions
diff --git a/parser/pageparser/pagelexer.go b/parser/pageparser/pagelexer.go
index 565be2994..fcea560c4 100644
--- a/parser/pageparser/pagelexer.go
+++ b/parser/pageparser/pagelexer.go
@@ -247,6 +247,9 @@ func lexMainSection(l *pageLexer) stateFunc {
// This makes it a little easier to reason about later.
l.consumeSpace()
l.emit(TypeLeadSummaryDivider)
+
+ // We have already moved to the next.
+ continue
}
}
diff --git a/parser/pageparser/pageparser_intro_test.go b/parser/pageparser/pageparser_intro_test.go
index 60c431c10..f818848bd 100644
--- a/parser/pageparser/pageparser_intro_test.go
+++ b/parser/pageparser/pageparser_intro_test.go
@@ -68,11 +68,14 @@ var frontMatterTests = []lexerTest{
{"Summary divider ORG", tstORG + "\nSome text.\n# more\nSome text.\n", []Item{tstFrontMatterORG, tstSomeText, nti(TypeLeadSummaryDivider, "# more\n"), nti(tText, "Some text.\n"), tstEOF}},
{"Summary divider", "+++\nfoo = \"bar\"\n+++\n\nSome text.\n<!--more-->\nSome text.\n", []Item{tstFrontMatterTOML, tstSomeText, tstSummaryDivider, nti(tText, "Some text.\n"), tstEOF}},
{"Summary divider same line", "+++\nfoo = \"bar\"\n+++\n\nSome text.<!--more-->Some text.\n", []Item{tstFrontMatterTOML, nti(tText, "\nSome text."), nti(TypeLeadSummaryDivider, "<!--more-->"), nti(tText, "Some text.\n"), tstEOF}},
+ // https://github.com/gohugoio/hugo/issues/5402
+ {"Summary and shortcode, no space", "+++\nfoo = \"bar\"\n+++\n\nSome text.\n<!--more-->{{< sc1 >}}\nSome text.\n", []Item{tstFrontMatterTOML, tstSomeText, nti(TypeLeadSummaryDivider, "<!--more-->"), tstLeftNoMD, tstSC1, tstRightNoMD, tstSomeText, tstEOF}},
}
func TestFrontMatter(t *testing.T) {
t.Parallel()
for i, test := range frontMatterTests {
+
items := collect([]byte(test.input), false, lexIntroSection)
if !equal(items, test.items) {
got := crLfReplacer.Replace(fmt.Sprint(items))