Skip to content
Myr

Fixed another bug with line comments

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent db7985d · Browse files · 2 files+4 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+4 added−4 removed

  • tests:+2 added−2 removed
  • other:+2 added−2 removed

2 files+4 added−4 removed

modified:jinja2/lexer.py+2 added-2 removed
142 unmodified lines
143 e(environment.comment_start_string)),144 (len(environment.block_start_string), 'block',145 e(environment.block_start_string)),146 (len(environment.variable_start_string), 'variable',147 e(environment.variable_start_string)),147 e(environment.variable_start_string))148 ]149150 if environment.line_statement_prefix is not None:151 rules.append((len(environment.line_statement_prefix), 'linestatement',152 r'^\s*' + e(environment.line_statement_prefix)))153 if environment.line_comment_prefix is not None:154 rules.append((len(environment.line_comment_prefix), 'linecomment',155 r'(?:^|(?<!\S))\s*' + e(environment.line_comment_prefix)))155 r'(?:^|(?<=\S))[^\S\r\n]*' + e(environment.line_comment_prefix)))156157 return [x[1:] for x in sorted(rules, reverse=True)]158159
473 unmodified lines
modified:tests/test_parser.py+2 added-2 removed
105 unmodified lines
106def test_line_syntax_priority():107 # XXX: why is the whitespace there in front of the newline?108 env = Environment('{%', '%}', '${', '}', '/*', '*/', '##', '#')109 tmpl = env.from_string(LINE_SYNTAX_PRIORITY1)110 assert tmpl.render(seq=[1, 2]).strip() == '* 1 \n* 2'110 assert tmpl.render(seq=[1, 2]).strip() == '* 1\n* 2'111 env = Environment('{%', '%}', '${', '}', '/*', '*/', '#', '##')112 tmpl = env.from_string(LINE_SYNTAX_PRIORITY2)113 assert tmpl.render(seq=[1, 2]).strip() == '* 1 \n* 2'113 assert tmpl.render(seq=[1, 2]).strip() == '* 1\n* 2'