From 53d582c4079d4b72c1a3ed0322e6bffb500e3b18 Mon Sep 17 00:00:00 2001 From: Eric Lapouyade Date: Tue, 27 Oct 2020 10:07:42 +0100 Subject: [PATCH] fix #320 --- CHANGES.rst | 4 ++++ docxtpl/__init__.py | 16 ++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index a81d7cd..891eaf9 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,7 @@ +0.11.1 (2020-10-27) +------------------- +- fix #320 + 0.11.0 (2020-10-19) ------------------- - \\n, \\a, \\t and \\f are now accepted in simple context string. Thanks to chabErch@github diff --git a/docxtpl/__init__.py b/docxtpl/__init__.py index b2cee80..4bb4b80 100644 --- a/docxtpl/__init__.py +++ b/docxtpl/__init__.py @@ -4,7 +4,7 @@ Created : 2015-03-12 @author: Eric Lapouyade """ -__version__ = '0.11.0' +__version__ = '0.11.1' import functools import io @@ -234,7 +234,7 @@ class DocxTemplate(object): def resolve_listing(self, xml): def resolve_text(run_properties, paragraph_properties, m): - xml = m[0].replace('\t', '' + xml = m.group(0).replace('\t', '' '%s' '%s' % (run_properties, run_properties)) xml = xml.replace('\a', '' @@ -246,18 +246,18 @@ class DocxTemplate(object): return xml def resolve_run(paragraph_properties, m): - run_properties = re.search(r'.*', m[0]) - run_properties = run_properties[0] if run_properties else '' + run_properties = re.search(r'.*', m.group(0)) + run_properties = run_properties.group(0) if run_properties else '' return re.sub(r']*)?>.*?', - lambda x: resolve_text(run_properties, paragraph_properties, x), m[0], + lambda x: resolve_text(run_properties, paragraph_properties, x), m.group(0), flags=re.DOTALL) def resolve_paragraph(m): - paragraph_properties = re.search(r'.*', m[0]) - paragraph_properties = paragraph_properties[0] if paragraph_properties else '' + paragraph_properties = re.search(r'.*', m.group(0)) + paragraph_properties = paragraph_properties.group(0) if paragraph_properties else '' return re.sub(r']*)?>.*?', lambda x: resolve_run(paragraph_properties, x), - m[0], flags=re.DOTALL) + m.group(0), flags=re.DOTALL) xml = re.sub(r']*)?>.*?', resolve_paragraph, xml, flags=re.DOTALL)