From d5c3e7dcec6c51b0bcbace55e5d6075b9d450da7 Mon Sep 17 00:00:00 2001 From: elapouya Date: Fri, 13 Mar 2015 17:11:52 +0100 Subject: [PATCH] add comment --- docxtpl/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docxtpl/__init__.py b/docxtpl/__init__.py index 55f50f6..06cbca1 100644 --- a/docxtpl/__init__.py +++ b/docxtpl/__init__.py @@ -47,8 +47,9 @@ class DocxTemplate(object): src_xml = re.sub(r'(](?:(?!]).)*){%\s*cellbg\s+([^%]*)\s*%}(.*?)',cellbg,src_xml,flags=re.DOTALL) for y in ['tr', 'p', 'r']: - # replace into xml code the row containing {%y xxx %} or {{y xxx}} template tag - # by {% xxx %} or {{ xx }} without any surronding xml tags. + # replace into xml code the row/paragraph/run containing {%y xxx %} or {{y xxx}} template tag + # by {% xxx %} or {{ xx }} without any surronding xml tags : + # This is mandatory to have jinja2 generating correct xml code pat = r'](?:(?!]).)*({%%|{{)%(y)s ([^}%%]*(?:%%}|}})).*?' % {'y':y} src_xml = re.sub(pat, r'\1 \2',src_xml,flags=re.DOTALL)