From fd6022f84ce8ee0fbb14d85ed846cabb31a5d56f Mon Sep 17 00:00:00 2001 From: ianb Date: Sat, 11 Apr 2009 02:34:45 +0000 Subject: fix issues with \r in expressions --- docs/index.txt | 2 ++ tempita/__init__.py | 8 ++++++-- 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( -- cgit v1.2.1