summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorianb <devnull@localhost>2009-04-11 02:34:45 +0000
committerianb <devnull@localhost>2009-04-11 02:34:45 +0000
commitfd6022f84ce8ee0fbb14d85ed846cabb31a5d56f (patch)
tree8e56ee8d10af7e5e47b7accdd1aaed7f371e3bba
parentdec8384da126b9aeefdf23660c0abcbf7f5a343b (diff)
downloadtempita-fd6022f84ce8ee0fbb14d85ed846cabb31a5d56f.tar.gz
fix issues with \r in expressions
-rw-r--r--docs/index.txt2
-rw-r--r--tempita/__init__.py8
2 files changed, 8 insertions, 2 deletions
diff --git a/docs/index.txt b/docs/index.txt
index a9b6814..44d412d 100644
--- a/docs/index.txt
+++ b/docs/index.txt
@@ -480,6 +480,8 @@ svn trunk
rules, and must be a module name) the template name is put into
``__template_name__``. This became important in Python 2.5.
+* Fix some issues with \r
+
0.3
---
diff --git a/tempita/__init__.py b/tempita/__init__.py
index b15031d..dfb2f91 100644
--- a/tempita/__init__.py
+++ b/tempita/__init__.py
@@ -770,8 +770,12 @@ def parse_expr(tokens, name, context=()):
expr = expr.strip()
if expr.startswith('py:'):
expr = expr[3:].lstrip(' \t')
- if expr.startswith('\n'):
- expr = expr[1:]
+ if expr.startswith('\n') or expr.startswith('\r'):
+ expr = expr.lstrip('\r\n')
+ if '\r' in expr:
+ expr = expr.replace('\r\n', '\n')
+ expr = expr.replace('\r', '')
+ expr += '\n'
else:
if '\n' in expr:
raise TemplateError(