Commit 37b4e3dc by Chris Jerdonek

Reduced the number of elements in the parse tree.

parent c8a1f2e1
...@@ -231,10 +231,6 @@ class _Parser(object): ...@@ -231,10 +231,6 @@ class _Parser(object):
match_index = match.start() match_index = match.start()
end_index = match.end() end_index = match.end()
# Avoid adding spurious empty strings to the parse tree.
if start_index != match_index:
parsed_template.add(template[start_index:match_index])
matches = match.groupdict() matches = match.groupdict()
# Normalize the matches dictionary. # Normalize the matches dictionary.
...@@ -259,10 +255,13 @@ class _Parser(object): ...@@ -259,10 +255,13 @@ class _Parser(object):
if end_index < len(template): if end_index < len(template):
end_index += template[end_index] == '\n' and 1 or 0 end_index += template[end_index] == '\n' and 1 or 0
elif leading_whitespace: elif leading_whitespace:
parsed_template.add(leading_whitespace)
match_index += len(leading_whitespace) match_index += len(leading_whitespace)
leading_whitespace = '' leading_whitespace = ''
# Avoid adding spurious empty strings to the parse tree.
if start_index != match_index:
parsed_template.add(template[start_index:match_index])
start_index = end_index start_index = end_index
if tag_type in ('#', '^'): if tag_type in ('#', '^'):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment