aboutsummaryrefslogtreecommitdiffstats
path: root/mako
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-02-02 11:41:34 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2012-02-02 11:41:34 -0500
commit1efbc0327aa00b5bdda724c9e76094826ae15a3f (patch)
tree49cd631f9c35bd9a165c13eeed9f34f770c06328 /mako
parentea3d1f2cf158d4ce5dd36ce79806058faddb8c48 (diff)
downloadexternal_python_mako-1efbc0327aa00b5bdda724c9e76094826ae15a3f.tar.gz
external_python_mako-1efbc0327aa00b5bdda724c9e76094826ae15a3f.tar.bz2
external_python_mako-1efbc0327aa00b5bdda724c9e76094826ae15a3f.zip
Fix for [ticket:20] and [ticket:86] much thanks to Eevee
Diffstat (limited to 'mako')
-rw-r--r--mako/__init__.py2
-rw-r--r--mako/lexer.py41
2 files changed, 22 insertions, 21 deletions
diff --git a/mako/__init__.py b/mako/__init__.py
index 0740ac1..40033ee 100644
--- a/mako/__init__.py
+++ b/mako/__init__.py
@@ -5,5 +5,5 @@
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-__version__ = '0.6.1'
+__version__ = '0.6.2'
diff --git a/mako/lexer.py b/mako/lexer.py
index 217674f..9e0bc5e 100644
--- a/mako/lexer.py
+++ b/mako/lexer.py
@@ -91,31 +91,32 @@ class Lexer(object):
def parse_until_text(self, *text):
startpos = self.match_position
+ text_re = r'|'.join(text)
+ brace_level = 0
while True:
match = self.match(r'#.*\n')
if match:
continue
- match = self.match(r'(\"\"\"|\'\'\'|\"|\')')
+ match = self.match(r'(\"\"\"|\'\'\'|\"|\')((?<!\\)\\\1|.)*?\1', re.S)
if match:
- m = self.match(r'.*?%s' % match.group(1), re.S)
- if not m:
- raise exceptions.SyntaxException(
- "Unmatched '%s'" %
- match.group(1),
- **self.exception_kwargs)
- else:
- match = self.match(r'(%s)' % r'|'.join(text))
- if match:
- return \
- self.text[startpos:self.match_position-len(match.group(1))],\
- match.group(1)
- else:
- match = self.match(r".*?(?=\"|\'|#|%s)" % r'|'.join(text), re.S)
- if not match:
- raise exceptions.SyntaxException(
- "Expected: %s" %
- ','.join(text),
- **self.exception_kwargs)
+ continue
+ match = self.match(r'(%s)' % text_re)
+ if match:
+ if match.group(1) == '}' and brace_level > 0:
+ brace_level -= 1
+ continue
+ return \
+ self.text[startpos:self.match_position-len(match.group(1))],\
+ match.group(1)
+ match = self.match(r"(.*?)(?=\"|\'|#|%s)" % text_re, re.S)
+ if match:
+ brace_level += match.group(1).count('{')
+ brace_level -= match.group(1).count('}')
+ continue
+ raise exceptions.SyntaxException(
+ "Expected: %s" %
+ ','.join(text),
+ **self.exception_kwargs)
def append_node(self, nodecls, *args, **kwargs):
kwargs.setdefault('source', self.text)