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

Small changes for identifing EX and NO

parent cde8014a
Loading
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -1933,10 +1933,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
@@ -1972,7 +1972,11 @@ 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')
            t1.text = matched_note
            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)
            
@@ -2015,7 +2019,11 @@ 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')
            t1.text = matched_example
            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)