Skip to content
Snippets Groups Projects
Commit 1e72f30c authored by Mike Bayer's avatar Mike Bayer
Browse files

- fix to lexing of <%docs> tag nested in other tags

parent 15350f3b
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@
expression-wise from the AST module [ticket:26]
- AST parsing, properly detects imports of the form "import foo.bar"
[ticket:27]
- fix to lexing of <%docs> tag nested in other tags
0.1.4
- got defs-within-defs to be cacheable
......
......@@ -305,7 +305,7 @@ class Lexer(object):
def match_comment(self):
"""matches the multiline version of a comment"""
match = self.match(r"<%doc>(.*)</%doc>", re.S)
match = self.match(r"<%doc>(.*?)</%doc>", re.S)
if match:
self.append_node(parsetree.Comment, match.group(1))
return True
......
......@@ -398,6 +398,20 @@ hi
"""
nodes = Lexer(template).parse()
assert repr(nodes) == r"""TemplateNode({}, [Text(u'\n<style>\n #someselector\n # other non comment stuff\n</style>\n', (1, 1)), Comment(u'a comment', (6, 1)), Text(u'\n# also not a comment\n\n', (7, 1)), Comment(u'this is a comment', (10, 1)), Text(u' \nthis is ## not a comment\n\n', (11, 1)), Comment(u' multiline\ncomment\n', (14, 1)), Text(u'\n\nhi\n', (16, 8))])"""
def test_docs(self):
template = """
<%doc>
this is a comment
</%doc>
<%def name="foo()">
<%doc>
this is the foo func
</%doc>
</%def>
"""
nodes = Lexer(template).parse()
assert repr(nodes) == r"""TemplateNode({}, [Text(u'\n ', (1, 1)), Comment(u'\n this is a comment\n ', (2, 9)), Text(u'\n ', (4, 16)), DefTag(u'def', {u'name': u'foo()'}, (5, 9), ["Text(u'\\n ', (5, 28))", "Comment(u'\\n this is the foo func\\n ', (6, 13))", "Text(u'\\n ', (8, 20))"]), Text(u'\n ', (9, 16))])"""
def test_preprocess(self):
def preproc(text):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment