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

Correction for H6 headings

parent 16dfc8d6
Loading
Loading
Loading
Loading
+8 −2
Original line number Original line Diff line number Diff line
@@ -685,7 +685,7 @@ def update_heading_styles(docx_input, docx_output):
    root = etree.fromstring(xml_data)
    root = etree.fromstring(xml_data)
    counter = 0
    counter = 0
    counter_annex = 0
    counter_annex = 0

    h6_counter = 0
    # Find all paragraphs with heading styles (Heading1, Heading2, etc.)
    # Find all paragraphs with heading styles (Heading1, Heading2, etc.)
    for para in root.xpath('.//w:p[w:pPr/w:pStyle[starts-with(@w:val, "Heading")]]', namespaces=ns):
    for para in root.xpath('.//w:p[w:pPr/w:pStyle[starts-with(@w:val, "Heading")]]', namespaces=ns):
        # Get all runs in this paragraph
        # Get all runs in this paragraph
@@ -750,8 +750,14 @@ def update_heading_styles(docx_input, docx_output):
            counter_annex += 1
            counter_annex += 1
        elif re.match(r'^\s*History\s*', full_text):
        elif re.match(r'^\s*History\s*', full_text):
            insert_page_break_before_heading(para, full_text)
            insert_page_break_before_heading(para, full_text)
        elif full_text.strip().lower() == "essential patents" or full_text.strip().lower() == "trademarks":
             # Change style from Heading 6 to H6
            pStyle_elems = para.xpath('./w:pPr/w:pStyle[@w:val="Heading6"]', namespaces=ns)
            if pStyle_elems:
                pStyle_elems[0].set(f"{{{ns['w']}}}val", "H6")
                h6_counter += 1
    
    
    print(f'Updated {counter} heading runs, {counter_annex} annex runs')
    print(f'Updated {counter} heading runs, {counter_annex} annex runs, {h6_counter} H6 runs')


    xml_data = etree.tostring(root, xml_declaration=True, encoding="UTF-8", standalone="yes")
    xml_data = etree.tostring(root, xml_declaration=True, encoding="UTF-8", standalone="yes")