[PATCH 2/2] only split multiline strings in output code at repr generated breaks
Doug Knight <[email protected]> Mon, 14 Dec 2009 16:36:09 -0900
| Newsgroups | gmane.comp.python.cheetah |
|---|---|
| Message-ID | <[email protected]> |
---
cheetah/Compiler.py | 4 ++--
cheetah/Parser.py | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/cheetah/Compiler.py b/cheetah/Compiler.py
index 248ba1f..a9a8570 100644
--- a/cheetah/Compiler.py
+++ b/cheetah/Compiler.py
@@ -438,13 +438,13 @@ class MethodCompiler(GenUtils):
if not strConst:
return
else:
- reprstr = repr(strConst).replace('\\012','\n')
+ reprstr = repr(strConst)
i = 0
out = []
if reprstr.startswith('u'):
i = 1
out = ['u']
- body = escapedNewlineRE.sub('\n', reprstr[i+1:-1])
+ body = escapedNewlineRE.sub('\\1\n', reprstr[i+1:-1])
if reprstr[i]=="'":
out.append("'''")
diff --git a/cheetah/Parser.py b/cheetah/Parser.py
index bb70d06..2fdeae5 100644
--- a/cheetah/Parser.py
+++ b/cheetah/Parser.py
@@ -153,7 +153,7 @@ unicodeDirectiveRE = re.compile(
encodingDirectiveRE = re.compile(
r'(?:^|\r\n|\r|\n)\s*#\s{0,5}encoding[:\s]*([-\w.]*)\s*(?:\r\n|\r|\n)', re.MULTILINE)
-escapedNewlineRE = re.compile(r'(?<!\\)\\n')
+escapedNewlineRE = re.compile(r'(?<!\\)((\\\\)*)\\(n|012)')
directiveNamesAndParsers = {
# importing and inheritance
--
1.6.5.2
------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev