Commit d6bea381 authored by Jonas Schüppen's avatar Jonas Schüppen
Browse files

Added special case for pagebreak in before heading: deal with bookmark starting directly before

parent e813119c
Loading
Loading
Loading
Loading
Loading
+8 −2
Changes for generateBaseline/postprocessing.py: 8 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -857,7 +857,13 @@ def update_heading_styles(docx_input, docx_output):
            return
        
        # Find the position of the "Scope" Heading1 paragraph
        para_index = list(parent).index(para)
        insert_index = list(parent).index(para)

        # Special case: BookmarkStart directly before
        if insert_index > 0:
            prev_elem = parent[insert_index - 1]
            if prev_elem.tag.endswith('}bookmarkStart'):
                insert_index -= 1
        
        # Create a new paragraph with a page break
        page_break_para = OxmlElement('w:p')
@@ -868,7 +874,7 @@ def update_heading_styles(docx_input, docx_output):
        page_break_para.append(page_break_run)
        
        # Insert the page break paragraph before the "Scope" Heading1 paragraph
        parent.insert(para_index, page_break_para)
        parent.insert(insert_index, page_break_para)
        print(f'Inserted page break before Heading: {heading_text}')

    def create_new_run(para, number, rest_text, tab_or_break = None):