Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/parser
diff options
context:
space:
mode:
authorJoshua Wong <joshwonghc@gmail.com>2020-01-18 09:33:15 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-01-18 13:24:10 +0300
commit21ca2e9ce4255bfad2bb0576aff087a240acf70a (patch)
tree42a3c6d5380019c52512743c7f02051e217a165d /parser
parent3efa1d81219a6e7b41c9676e9cab446741f69055 (diff)
Add support for newline characters in raw string shortcode
Diffstat (limited to 'parser')
-rw-r--r--parser/pageparser/pagelexer_shortcode.go2
-rw-r--r--parser/pageparser/pageparser_shortcode_test.go6
2 files changed, 7 insertions, 1 deletions
diff --git a/parser/pageparser/pagelexer_shortcode.go b/parser/pageparser/pagelexer_shortcode.go
index 8238425bf..61ba43f2c 100644
--- a/parser/pageparser/pagelexer_shortcode.go
+++ b/parser/pageparser/pagelexer_shortcode.go
@@ -165,7 +165,7 @@ Loop:
openBacktickFound = true
l.ignore()
}
- case r == eof, r == '\n':
+ case r == eof:
return l.errorf("unterminated raw string in shortcode parameter-argument: '%s'", l.current())
}
}
diff --git a/parser/pageparser/pageparser_shortcode_test.go b/parser/pageparser/pageparser_shortcode_test.go
index 8d1ebda2f..b8bf5f727 100644
--- a/parser/pageparser/pageparser_shortcode_test.go
+++ b/parser/pageparser/pageparser_shortcode_test.go
@@ -89,6 +89,12 @@ var shortCodeLexerTests = []lexerTest{
tstLeftNoMD, tstSC1, nti(tScParam, "-ziL-.%QigdO-4"), tstRightNoMD, tstEOF}},
{"raw string", `{{< sc1` + "`" + "Hello World" + "`" + ` >}}`, []Item{
tstLeftNoMD, tstSC1, nti(tScParam, "Hello World"), tstRightNoMD, tstEOF}},
+ {"raw string with newline", `{{< sc1` + "`" + `Hello
+ World` + "`" + ` >}}`, []Item{
+ tstLeftNoMD, tstSC1, nti(tScParam, `Hello
+ World`), tstRightNoMD, tstEOF}},
+ {"raw string with escape character", `{{< sc1` + "`" + `Hello \b World` + "`" + ` >}}`, []Item{
+ tstLeftNoMD, tstSC1, nti(tScParam, `Hello \b World`), tstRightNoMD, tstEOF}},
{"two params", `{{< sc1 param1 param2 >}}`, []Item{
tstLeftNoMD, tstSC1, tstParam1, tstParam2, tstRightNoMD, tstEOF}},
// issue #934