From 630dfe996f3a919f620bf3c1efd89375e1f01387 Mon Sep 17 00:00:00 2001 From: elapouya Date: Wed, 4 Nov 2015 17:59:29 +0100 Subject: [PATCH] Try a fix ... --- docxtpl/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docxtpl/__init__.py b/docxtpl/__init__.py index 7d105ff..5244a3b 100644 --- a/docxtpl/__init__.py +++ b/docxtpl/__init__.py @@ -5,7 +5,7 @@ Created : 2015-03-12 @author: Eric Lapouyade ''' -__version__ = '0.1.7' +__version__ = '0.1.8' from lxml import etree from docx import Document @@ -35,6 +35,9 @@ class DocxTemplate(object): def patch_xml(self,src_xml): # strip all xml tags inside {% %} and {{ }} # that Microsoft word can insert into xml code for this part of the document + + # A essayer : src_xml = re.sub(r'(?<={)(<[^>]*>)+(?=[\{%])|(?<=[%\}])(<[^>]*>)+(?=\})','',src_xml,flags=re.DOTALL) + def striptags(m): return re.sub('.*?(|]*>)','',m.group(0),flags=re.DOTALL) src_xml = re.sub(r'{%(?:(?!%}).)*|{{(?:(?!}}).)*',striptags,src_xml,flags=re.DOTALL)