diff --git a/CHANGES.rst b/CHANGES.rst index a86cdd5..701b9ef 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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 : diff --git a/docxtpl/__init__.py b/docxtpl/__init__.py index 9facb27..2c55277 100644 --- a/docxtpl/__init__.py +++ b/docxtpl/__init__.py @@ -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'](?:(?!]).)*({%%|{{)%(y)s ([^}%%]*(?:%%}|}})).*?' % {'y':y} 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 diff --git a/tests/test_files/cellbg.docx b/tests/test_files/cellbg.docx index 606cee7..5a92303 100644 Binary files a/tests/test_files/cellbg.docx and b/tests/test_files/cellbg.docx differ diff --git a/tests/test_files/order.docx b/tests/test_files/order.docx index afba0a7..5c6d7fd 100644 Binary files a/tests/test_files/order.docx and b/tests/test_files/order.docx differ diff --git a/tests/test_files/richtext.docx b/tests/test_files/richtext.docx index 50f772f..84cd9eb 100644 Binary files a/tests/test_files/richtext.docx and b/tests/test_files/richtext.docx differ diff --git a/tests/test_files/subdoc.docx b/tests/test_files/subdoc.docx index 2466f8a..600e27d 100644 Binary files a/tests/test_files/subdoc.docx and b/tests/test_files/subdoc.docx differ