Fix '{% vm %}' tag for table cells with XML attributes

Updated regex to match cell content inside '<w:t>' even if <w:t> has XML
attributes such as 'xml:space="preserve"'. Updated test to have this kind
of '<w:t>'.
This commit is contained in:
Nick Gashkov 2018-09-12 12:14:56 +03:00
parent 4b0b1da2eb
commit 98ad7eebf7
3 changed files with 1 additions and 1 deletions

View File

@ -103,7 +103,7 @@ class DocxTemplate(object):
m1.group(4) # ``</w:t>``.
)
return re.sub(
r'(</w:tcPr>.*?<w:t>)(.*?)(?:{%\s*vm\s*%})(.*?)(</w:t>)',
r'(</w:tcPr[ >].*?<w:t(?:.*?)>)(.*?)(?:{%\s*vm\s*%})(.*?)(</w:t>)',
vMerge,
m.group(), # Everything between ``</w:tc>`` and ``</w:tc>`` with ``{% vm %}`` inside.
flags=re.DOTALL,