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

Some Modifications for NOTES and EXAMPLES

parent 7897e399
Loading
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -1009,10 +1009,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
@@ -1048,7 +1048,13 @@ 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 = example_match.group(1)  # "" oder z.B. "3"
            if number:
                t1.text = f"NOTE {number}:"
            else:
                t1.text = "NOTE:"

            r1.append(t1)
            para.append(r1)

@@ -1091,7 +1097,13 @@ 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)