Fixed an escaping issue for nested inlinefuncs.

This commit is contained in:
Griatch 2015-11-29 18:26:19 +01:00
parent 0c08f7c550
commit 9587f400ac
2 changed files with 7 additions and 2 deletions

View file

@ -189,7 +189,7 @@ _RE_TOKEN = re.compile(r"""
(?P<end>(?<!\\)\))| # unescaped } (end of function call)
(?P<start>(?<!\\)\$\w+\()| # unescaped $funcname{ (start of function call)
(?P<escaped>\\'|\\"|\\\)|\\$\w+\()| # escaped tokens should re-appear in text
(?P<rest>[\w\s.-\/#!%\^&\*;:=\-\"\'_`~\(}{\[\]]+) # everything else should also be included""",
(?P<rest>[\w\s.-\/#!%\^&\*;:=\-_`~\(}{\[\]]+|\"{1}|\'{1}) # everything else should also be included""",
re.UNICODE + re.IGNORECASE + re.VERBOSE + re.DOTALL)

View file

@ -336,5 +336,10 @@ class TestNestedInlineFuncs(TestCase):
def test_escaped(self):
self.assertEqual(nested_inlinefuncs.parse_inlinefunc(
"this should be $pad('''escaped,''' and \"\"\"instead,\"\"\" cropped $crop(with a long,5) text., 80)"),
"this should be $pad('''escaped,''' and '''instead,''' cropped $crop(with a long,5) text., 80)"),
"this should be escaped, and instead, cropped with text. ")
def test_escaped2(self):
self.assertEqual(nested_inlinefuncs.parse_inlinefunc(
'this should be $pad("""escaped,""" and """instead,""" cropped $crop(with a long,5) text., 80)'),
"this should be escaped, and instead, cropped with text. ")