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

Some changes according to german language installations

parent f97745c1
Loading
Loading
Loading
Loading
Loading
+17 −9
Original line number Diff line number Diff line
@@ -674,7 +674,7 @@ def update_heading_styles(docx_input, docx_output):
    counter_annex = 0
    h6_counter = 0
    # 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") or starts-with(@val, "berschrift")]]', namespaces=ns):
        # Get all runs in this paragraph
        runs = para.xpath('.//w:r', namespaces=ns)
        if not runs:
@@ -1485,7 +1485,7 @@ def update_notes(docx_input, docx_output):
    counter_ew = 0

    # Loop over all elements to find "BlockText" and change to "NO"
    for pStyle_elem in root.xpath('.//w:pStyle[@w:val="BlockText"]', namespaces=ns):
    for pStyle_elem in root.xpath('.//w:pStyle[@w:val="BlockText" or @w:val="Blocktext"]', namespaces=ns):
        # Find the paragraph that contains this pStyle
        para = pStyle_elem
        while para is not None and para.tag != f"{{{ns['w']}}}p":
@@ -1508,10 +1508,10 @@ def update_notes(docx_input, docx_output):
        all_children = [child for child in para if child.tag != f"{{{ns['w']}}}pPr"]
        
        # Check if text matches NOTE pattern: NOTE\s*\d*:
        note_pattern = re.compile(r'NOTE\s*\d*:\s+')
        note_pattern = re.compile(r'NOTE\s*(\d*)\s*:\s*')
        note_match = note_pattern.search(full_text)
        # Check if text matches EXAMPLE pattern: EXAMPLE\s*\d*:
        example_pattern = re.compile(r'EXAMPLE\s*\d*:\s+')
        example_pattern = re.compile(r'EXAMPLE\s*(\d*)\s*:\s*')
        example_match = example_pattern.search(full_text)
        if note_match:
            # Change style to NO
@@ -1547,6 +1547,10 @@ def update_notes(docx_input, docx_output):
            # Create new runs: r1="NOTE:" r2="tab" and append all original children
            r1 = OxmlElement('w:r')
            t1 = OxmlElement('w:t')
            number = note_match.group(1)  # "" oder z.B. "3"
            if number:
                t1.text = f"NOTE {number}:"
            else:
                t1.text = "NOTE:"
            r1.append(t1)
            para.append(r1)
@@ -1590,6 +1594,10 @@ def update_notes(docx_input, docx_output):
            # Create new runs: r1="EXAMPLE:" r2="tab" and append all original children
            r1 = OxmlElement('w:r')
            t1 = OxmlElement('w:t')
            number = example_match.group(1)  # "" oder z.B. "3"
            if number:
                t1.text = f"EXAMPLE {number}:"
            else:
                t1.text = "EXAMPLE:"
            r1.append(t1)
            para.append(r1)
@@ -1656,7 +1664,7 @@ def update_abbreviations(docx_input, docx_output):
    counter = 0

    # Find all paragraphs with BodyText style
    paragraphs_to_process = root.xpath('.//w:p[w:pPr/w:pStyle[@w:val="BodyText"]]', namespaces=ns)
    paragraphs_to_process = root.xpath('.//w:p[w:pPr/w:pStyle[@w:val="BodyText" or @w:val="Textkrper"]]', namespaces=ns)
    
    for para in paragraphs_to_process:
        # Check if this paragraph contains runs with Verbatim or VerbatimChar style
@@ -1783,7 +1791,7 @@ def update_references(docx_input, docx_output):
    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):
    for para in root.xpath('.//w:p[w:pPr/w:pStyle[@w:val="BodyText" or @w:val="Textkrper]]', 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)
@@ -1888,7 +1896,7 @@ def update_body_text_style(docx_input, docx_output):

    # Loop over all elements to find "BodyText" and "FirstParagraph" and change to "Normal"
    # Combine both XPath queries
    body_text_elems = root.xpath('.//w:pStyle[@w:val="BodyText"]', namespaces=ns)
    body_text_elems = root.xpath('.//w:pStyle[@w:val="BodyText" or @w:val="Textkrper]', namespaces=ns)
    first_para_elems = root.xpath('.//w:pStyle[@w:val="FirstParagraph"]', namespaces=ns)
    all_elems = body_text_elems + first_para_elems