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

Add page break before any Annex clause

parent aa2066fb
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -758,8 +758,8 @@ def update_heading_styles(docx_input, docx_output):
            # Insert page break before "Scope" Heading1 and "History" Heading1
            if re.match(r'^1\s+Scope\s*', full_text):
                insert_page_break_before_heading(para, full_text)
        # Annex heading: "Annex A: Title" or "Annex A (informative): Title"
        elif (match := re.match(r'^(Annex\s[A-Z](?:\s*\((?:informative|normative|informative or normative|normative or informative)\))?:)\s*(.+)$', full_text, re.IGNORECASE)) is not None:
        # Annex heading: "Annex A: Title" or "Annex A (informative): Title" or "Annex: Title"
        elif (match := re.match(r'^(Annex\s[A-Z](?:\s*\((?:informative|normative|informative or normative|normative or informative)\))?:|Annex:\s*)\s*(.+)$', full_text, re.IGNORECASE)) is not None:
            annex_letter = match.group(1)
            annex_title = match.group(2)
            
@@ -773,6 +773,7 @@ def update_heading_styles(docx_input, docx_output):
            pStyle_elems = para.xpath('./w:pPr/w:pStyle[@w:val="Heading1"]', namespaces=ns)
            if pStyle_elems:
                pStyle_elems[0].set(f"{{{ns['w']}}}val", "Heading8")  
            insert_page_break_before_heading(para, full_text)  
            counter_annex += 1
        # Annex subheading Heading 2: "A.1 Title", not matching "A.1.1 Title"
        elif (match := re.match(r'^\s*([A-Z]\.\d+)\s+(.+)$', full_text)) is not None:
@@ -1971,7 +1972,7 @@ def update_body_text_style(docx_input, docx_output):
            print(f'Changed style to "H6" for: "{full_text_stripped}"')
        elif re.match(r'^Editor[\'’]s\s+Note:', full_text_stripped, re.IGNORECASE):
            elem.set(f"{{{ns['w']}}}val", new_style)
            print(f'Changed style to "NO" for "Editor\'s Note:" "{full_text_stripped}"')
            print(f'Changed style to "{new_style}" for "Editor\'s Note:" "{full_text_stripped}"')
            
            # Add yellow highlighting to all runs in this paragraph (including runs inside hyperlinks)
            all_runs = para.xpath('.//w:r', namespaces=ns)
@@ -2469,12 +2470,12 @@ def update_format_styles_cli():
    update_figure_captions(args.docx_input, args.docx_output)
    update_heading_styles(args.docx_input, args.docx_output)
    update_figure_style(args.docx_input, args.docx_output)
    update_unnumbered_lists(args.docx_input, args.docx_output)
    update_table_captions(args.docx_input, args.docx_output)
    update_abbreviations(args.docx_input, args.docx_output)
    update_table_rows(args.docx_input, args.docx_output)
    update_notes(args.docx_input, args.docx_output)
    update_references(args.docx_input, args.docx_output)
    update_unnumbered_lists(args.docx_input, args.docx_output)
    update_body_text_style(args.docx_input, args.docx_output)
    add_no_break_hyphens(args.docx_input, args.docx_output)
    update_references_style(args.docx_input, args.docx_output)