Fixed another bug with line comments
--HG--
branch : trunk
diff --git a/jinja2/lexer.py b/jinja2/lexer.py
index 8f63932..3a925bb 100644
--- a/jinja2/lexer.py
+++ b/jinja2/lexer.py
@@ -144,7 +144,7 @@
(len(environment.block_start_string), 'block',
e(environment.block_start_string)),
(len(environment.variable_start_string), 'variable',
- e(environment.variable_start_string)),
+ e(environment.variable_start_string))
]
if environment.line_statement_prefix is not None:
@@ -152,7 +152,7 @@
r'^\s*' + e(environment.line_statement_prefix)))
if environment.line_comment_prefix is not None:
rules.append((len(environment.line_comment_prefix), 'linecomment',
- r'(?:^|(?<!\S))\s*' + e(environment.line_comment_prefix)))
+ r'(?:^|(?<=\S))[^\S\r\n]*' + e(environment.line_comment_prefix)))
return [x[1:] for x in sorted(rules, reverse=True)]
diff --git a/tests/test_parser.py b/tests/test_parser.py
index 9ee6003..8d39ab0 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -107,7 +107,7 @@
# XXX: why is the whitespace there in front of the newline?
env = Environment('{%', '%}', '${', '}', '/*', '*/', '##', '#')
tmpl = env.from_string(LINE_SYNTAX_PRIORITY1)
- assert tmpl.render(seq=[1, 2]).strip() == '* 1 \n* 2'
+ assert tmpl.render(seq=[1, 2]).strip() == '* 1\n* 2'
env = Environment('{%', '%}', '${', '}', '/*', '*/', '#', '##')
tmpl = env.from_string(LINE_SYNTAX_PRIORITY2)
- assert tmpl.render(seq=[1, 2]).strip() == '* 1 \n* 2'
+ assert tmpl.render(seq=[1, 2]).strip() == '* 1\n* 2'