@@ -1587,7 +1587,7 @@ class Parser {
15871587 auto left = parseStringConcat ();
15881588 if (!left) throw std::runtime_error (" Expected left side of 'logical compare' expression" );
15891589
1590- static std::regex compare_tok (R"( ==|!=|<=?|>=?|in\b|is\b|not[\n\s]+in\b)" );
1590+ static std::regex compare_tok (R"( ==|!=|<=?|>=?|in\b|is\b|not[\r\ n\s]+in\b)" );
15911591 static std::regex not_tok (R"( not\b)" );
15921592 std::string op_str;
15931593 while (!(op_str = consumeToken (compare_tok)).empty ()) {
@@ -1957,7 +1957,7 @@ class Parser {
19571957 using TemplateTokenIterator = TemplateTokenVector::const_iterator;
19581958
19591959 std::vector<std::string> parseVarNames () {
1960- static std::regex varnames_regex (R"( ((?:\w+)(?:[\n\s]*,[\n\s]*(?:\w+))*)[\n\s]*)" );
1960+ static std::regex varnames_regex (R"( ((?:\w+)(?:[\r\ n\s]*,[\r\ n\s]*(?:\w+))*)[\r \n\s]*)" );
19611961
19621962 std::vector<std::string> group;
19631963 if ((group = consumeTokenGroups (varnames_regex)).empty ()) throw std::runtime_error (" Expected variable names" );
@@ -1982,11 +1982,11 @@ class Parser {
19821982 TemplateTokenVector tokenize () {
19831983 static std::regex comment_tok (R"( \{#([-~]?)(.*?)([-~]?)#\})" );
19841984 static std::regex expr_open_regex (R"( \{\{([-~])?)" );
1985- static std::regex block_open_regex (R"( ^\{%([-~])?[\s\n]*)" );
1985+ static std::regex block_open_regex (R"( ^\{%([-~])?[\s\n\r ]*)" );
19861986 static std::regex block_keyword_tok (R"( (if|else|elif|endif|for|endfor|set|endset|block|endblock|macro|endmacro)\b)" );
1987- static std::regex text_regex (R"( [\s\S\n]*?($|(?=\{\{|\{%|\{#)))" );
1988- static std::regex expr_close_regex (R"( [\s\n]*([-~])?\}\})" );
1989- static std::regex block_close_regex (R"( [\s\n]*([-~])?%\})" );
1987+ static std::regex text_regex (R"( [\s\S\n\r ]*?($|(?=\{\{|\{%|\{#)))" );
1988+ static std::regex expr_close_regex (R"( [\s\n\r ]*([-~])?\}\})" );
1989+ static std::regex block_close_regex (R"( [\s\n\r ]*([-~])?%\})" );
19901990
19911991 TemplateTokenVector tokens;
19921992 std::vector<std::string> group;
@@ -2063,7 +2063,7 @@ class Parser {
20632063 auto post_space = parseBlockClose ();
20642064 tokens.push_back (nonstd_make_unique<EndForTemplateToken>(location, pre_space, post_space));
20652065 } else if (keyword == " set" ) {
2066- static std::regex namespaced_var_regex (R"( (\w+)[\s\n]*\.[\s\n]*(\w+))" );
2066+ static std::regex namespaced_var_regex (R"( (\w+)[\s\n\r ]*\.[\s\n\r ]*(\w+))" );
20672067
20682068 std::string ns;
20692069 std::vector<std::string> var_names;
@@ -2158,19 +2158,19 @@ class Parser {
21582158 static std::regex leading_space_regex (R"( ^(\s|\r|\n)+)" );
21592159 text = std::regex_replace (text, leading_space_regex, " " );
21602160 } else if (options.trim_blocks && (it - 1 ) != begin && !dynamic_cast <ExpressionTemplateToken*>((*(it - 2 )).get ())) {
2161- static std::regex leading_line (R"( ^[ \t]*\n)" );
2161+ static std::regex leading_line (R"( ^[ \t]*\r?\ n)" );
21622162 text = std::regex_replace (text, leading_line, " " );
21632163 }
21642164 if (post_space == SpaceHandling::Strip) {
21652165 static std::regex trailing_space_regex (R"( (\s|\r|\n)+$)" );
21662166 text = std::regex_replace (text, trailing_space_regex, " " );
21672167 } else if (options.lstrip_blocks && it != end) {
2168- static std::regex trailing_last_line_space_regex (R"( (\n)[ \t]*$)" );
2168+ static std::regex trailing_last_line_space_regex (R"( (\r?\ n)[ \t]*$)" );
21692169 text = std::regex_replace (text, trailing_last_line_space_regex, " $1" );
21702170 }
21712171
21722172 if (it == end && !options.keep_trailing_newline ) {
2173- static std::regex r (R"( [\n\r] $)" );
2173+ static std::regex r (R"( \r?\n $)" );
21742174 text = std::regex_replace (text, r, " " ); // Strip one trailing newline
21752175 }
21762176 children.emplace_back (nonstd_make_unique<TextNode>(token->location , text));
0 commit comments