Commit 4799c0df authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Fix for references having FirstParagraph as style

parent 483321db
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1897,11 +1897,11 @@ def update_references(docx_input, docx_output):
    new_style = "EX"
    counter = 0

    # Loop over all paragraphs with style "BodyText" and change to "EX"
    for para in root.xpath('.//w:p[w:pPr/w:pStyle[@w:val="BodyText"]]', namespaces=ns):
    # Loop over all paragraphs with style "BodyText" or "FirstParagraph" and change to "EX"
    for para in root.xpath('.//w:p[w:pPr/w:pStyle[@w:val="BodyText" or @w:val="FirstParagraph"]]', namespaces=ns):
        old_val = para.get(f"{{{ns['w']}}}val")
        # A reference is a paragraph that contains:
        # - A pPr with pStyle "BodyText" (already checked in loop)
        # - A pPr with pStyle "BodyText" or "FirstParagraph" (already checked in loop)
        # - A bookmarkStart and a bookmarkEnd
        # - A run with text matching either \[\d+\] or \[i\.\d+\]
        # - An hyperlink element