diff --git a/include/minja/minja.hpp b/include/minja/minja.hpp index e77eb69..0eadae8 100644 --- a/include/minja/minja.hpp +++ b/include/minja/minja.hpp @@ -2194,7 +2194,7 @@ class Parser { } TemplateTokenVector tokenize() { - static std::regex comment_tok(R"(\{#([-~]?)(.*?)([-~]?)#\})"); + static std::regex comment_tok(R"(\{#([-~]?)([\s\S\r\n]*?)([-~]?)#\})"); static std::regex expr_open_regex(R"(\{\{([-~])?)"); static std::regex block_open_regex(R"(^\{%([-~])?[\s\n\r]*)"); 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)"); diff --git a/tests/test-syntax.cpp b/tests/test-syntax.cpp index 1d85c61..b6f6d57 100644 --- a/tests/test-syntax.cpp +++ b/tests/test-syntax.cpp @@ -74,6 +74,10 @@ TEST(SyntaxTest, SimpleCases) { return testing::Throws(Property(&std::runtime_error::what, testing::HasSubstr(expected_substr))); }; + EXPECT_EQ( + "ok", + render("{# Hey\nHo #}{#- Multiline...\nComments! -#}{{ 'ok' }}{# yo #}", {}, {})); + EXPECT_EQ( " b", render(R"( {% set _ = 1 %} {% set _ = 2 %}b)", {}, lstrip_trim_blocks));