fix '>' '<' in jinja tags
This commit is contained in:
parent
d9ee9620e5
commit
f599a5d3ee
@ -1,3 +1,7 @@
|
|||||||
|
0.1.11 (2016-3-1)
|
||||||
|
-----------------
|
||||||
|
- '>' and '<' can now be used inside jinja tags
|
||||||
|
|
||||||
0.1.10 (2016-2-11)
|
0.1.10 (2016-2-11)
|
||||||
------------------
|
------------------
|
||||||
- render() accepts optionnal jinja_env argument :
|
- render() accepts optionnal jinja_env argument :
|
||||||
|
|||||||
@ -5,7 +5,7 @@ Created : 2015-03-12
|
|||||||
@author: Eric Lapouyade
|
@author: Eric Lapouyade
|
||||||
'''
|
'''
|
||||||
|
|
||||||
__version__ = '0.1.10'
|
__version__ = '0.1.11'
|
||||||
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
from docx import Document
|
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}
|
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 = re.sub(pat, r'\1 \2',src_xml,flags=re.DOTALL)
|
||||||
|
|
||||||
src_xml = src_xml.replace(r"‘","'")
|
def clean_tags(m):
|
||||||
|
return m.group(0).replace(r"‘","'").replace('<','<').replace('>','>')
|
||||||
|
src_xml = re.sub(r'(?<=\{[\{%])([^\}%]*)(?=[\}%]})',clean_tags,src_xml)
|
||||||
|
|
||||||
return src_xml
|
return src_xml
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user