From af2e09209bab2486a55c4ab8ef677fee7ad73af6 Mon Sep 17 00:00:00 2001 From: Adrian Vorobel Date: Fri, 5 May 2023 12:44:04 +0300 Subject: [PATCH] Fix: add whitespace to regexp, as they capture wrong xml tags (w:tc, w:tcBorders, etc.) --- docxtpl/template.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docxtpl/template.py b/docxtpl/template.py index 843aade..943bf29 100644 --- a/docxtpl/template.py +++ b/docxtpl/template.py @@ -294,18 +294,18 @@ class DocxTemplate(object): def resolve_run(paragraph_properties, m): run_properties = re.search(r'.*?', m.group(0)) run_properties = run_properties.group(0) if run_properties else '' - return re.sub(r']*)?>.*?', + return re.sub(r']*)?>.*?', 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.group(0)) paragraph_properties = paragraph_properties.group(0) if paragraph_properties else '' - return re.sub(r']*)?>.*?', + return re.sub(r']*)?>.*?', lambda x: resolve_run(paragraph_properties, x), m.group(0), flags=re.DOTALL) - xml = re.sub(r']*)?>.*?', resolve_paragraph, xml, flags=re.DOTALL) + xml = re.sub(r']*)?>.*?', resolve_paragraph, xml, flags=re.DOTALL) return xml