Skip to content

Commit

Permalink
Merge branch 'quintagroup-fix/resolve_listing_function'
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Lapouyade committed May 8, 2023
2 parents d9801fd + af2e092 commit d042d45
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docxtpl/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,18 +294,18 @@ def resolve_text(run_properties, paragraph_properties, m):
def resolve_run(paragraph_properties, m):
run_properties = re.search(r'<w:rPr>.*?</w:rPr>', m.group(0))
run_properties = run_properties.group(0) if run_properties else ''
return re.sub(r'<w:t(?:[^>]*)?>.*?</w:t>',
return re.sub(r'<w:t(?: [^>]*)?>.*?</w:t>',
lambda x: resolve_text(run_properties, paragraph_properties, x), m.group(0),
flags=re.DOTALL)

def resolve_paragraph(m):
paragraph_properties = re.search(r'<w:pPr>.*?</w:pPr>', m.group(0))
paragraph_properties = paragraph_properties.group(0) if paragraph_properties else ''
return re.sub(r'<w:r(?:[^>]*)?>.*?</w:r>',
return re.sub(r'<w:r(?: [^>]*)?>.*?</w:r>',
lambda x: resolve_run(paragraph_properties, x),
m.group(0), flags=re.DOTALL)

xml = re.sub(r'<w:p(?:[^>]*)?>.*?</w:p>', resolve_paragraph, xml, flags=re.DOTALL)
xml = re.sub(r'<w:p(?: [^>]*)?>.*?</w:p>', resolve_paragraph, xml, flags=re.DOTALL)

return xml

Expand Down

0 comments on commit d042d45

Please sign in to comment.