Skip to content

Commit 65960fb

Browse files
authored
Merge pull request #45 from google/multiline-comments
Fix multiline comments (. isn't multiline, need [\s\S\r\n])
2 parents 693e2f2 + 88b1788 commit 65960fb

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

include/minja/minja.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2194,7 +2194,7 @@ class Parser {
21942194
}
21952195

21962196
TemplateTokenVector tokenize() {
2197-
static std::regex comment_tok(R"(\{#([-~]?)(.*?)([-~]?)#\})");
2197+
static std::regex comment_tok(R"(\{#([-~]?)([\s\S\r\n]*?)([-~]?)#\})");
21982198
static std::regex expr_open_regex(R"(\{\{([-~])?)");
21992199
static std::regex block_open_regex(R"(^\{%([-~])?[\s\n\r]*)");
22002200
static std::regex block_keyword_tok(R"((if|else|elif|endif|for|endfor|generation|endgeneration|set|endset|block|endblock|macro|endmacro|filter|endfilter|break|continue)\b)");

tests/test-syntax.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ TEST(SyntaxTest, SimpleCases) {
7474
return testing::Throws<std::runtime_error>(Property(&std::runtime_error::what, testing::HasSubstr(expected_substr)));
7575
};
7676

77+
EXPECT_EQ(
78+
"ok",
79+
render("{# Hey\nHo #}{#- Multiline...\nComments! -#}{{ 'ok' }}{# yo #}", {}, {}));
80+
7781
EXPECT_EQ(
7882
" b",
7983
render(R"( {% set _ = 1 %} {% set _ = 2 %}b)", {}, lstrip_trim_blocks));

0 commit comments

Comments
 (0)