fix '>' '<' in jinja tags

This commit is contained in:
Eric Lapouyade 2016-03-01 15:26:53 +01:00
parent d9ee9620e5
commit f599a5d3ee
6 changed files with 8 additions and 2 deletions

View File

@ -1,3 +1,7 @@
0.1.11 (2016-3-1)
-----------------
- '>' and '<' can now be used inside jinja tags
0.1.10 (2016-2-11)
------------------
- render() accepts optionnal jinja_env argument :

View File

@ -5,7 +5,7 @@ Created : 2015-03-12
@author: Eric Lapouyade
'''
__version__ = '0.1.10'
__version__ = '0.1.11'
from lxml import etree
from docx import Document
@ -55,7 +55,9 @@ class DocxTemplate(object):
pat = r'<w:%(y)s[ >](?:(?!<w:%(y)s[ >]).)*({%%|{{)%(y)s ([^}%%]*(?:%%}|}})).*?</w:%(y)s>' % {'y':y}
src_xml = re.sub(pat, r'\1 \2',src_xml,flags=re.DOTALL)
src_xml = src_xml.replace(r"&#8216;","'")
def clean_tags(m):
return m.group(0).replace(r"&#8216;","'").replace('&lt;','<').replace('&gt;','>')
src_xml = re.sub(r'(?<=\{[\{%])([^\}%]*)(?=[\}%]})',clean_tags,src_xml)
return src_xml

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.