diff --git a/docxtpl/__init__.py b/docxtpl/__init__.py index 9f70ff8..1cc6eca 100644 --- a/docxtpl/__init__.py +++ b/docxtpl/__init__.py @@ -7,7 +7,7 @@ Created : 2015-03-12 import functools import io -__version__ = '0.6.1' +__version__ = '0.6.2' from lxml import etree from docx import Document @@ -99,8 +99,12 @@ class DocxTemplate(object): cellbg,src_xml,flags=re.DOTALL) # avoid {{r and {%r tags to strip MS xml tags too far + # ensure space preservation when splitting + src_xml = re.sub(r'((?:(?!).)*)({{r\s.*?}}|{%r\s.*?%})', + r'\1\2', + src_xml,flags=re.DOTALL) src_xml = re.sub(r'({{r\s.*?}}|{%r\s.*?%})', - r'\1', + r'\1', src_xml,flags=re.DOTALL) for y in ['tr', 'tc', 'p', 'r']: