diff --git a/docxtpl/template.py b/docxtpl/template.py index f20280a..7886480 100644 --- a/docxtpl/template.py +++ b/docxtpl/template.py @@ -183,7 +183,7 @@ def cellbg(m): # by {% xxx %} or {{ xx }} without any surrounding tags : # This is mandatory to have jinja2 generating correct xml code pat = ( - r"](?:(?!]).)*({%%|{{)%(y)s ([^}%%]*(?:%%}|}})).*?" + r"](?:(?!]).)*({%%|{{)%(y)s ((?:(?!%%}|}}).)*(?:%%}|}})).*?" % {"y": y} ) src_xml = re.sub(pat, r"\1 \2", src_xml, flags=re.DOTALL)