Loading generateBaseline/postprocessing.py +17 −5 Original line number Diff line number Diff line Loading @@ -1618,7 +1618,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"]', namespaces=ns): # Find the paragraph that contains this pStyle para = pStyle_elem while para is not None and para.tag != f"{{{ns['w']}}}p": Loading @@ -1641,10 +1641,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 Loading Loading @@ -1680,7 +1680,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') 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) Loading Loading @@ -1723,7 +1729,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') 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) Loading Loading
generateBaseline/postprocessing.py +17 −5 Original line number Diff line number Diff line Loading @@ -1618,7 +1618,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"]', namespaces=ns): # Find the paragraph that contains this pStyle para = pStyle_elem while para is not None and para.tag != f"{{{ns['w']}}}p": Loading @@ -1641,10 +1641,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 Loading Loading @@ -1680,7 +1680,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') 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) Loading Loading @@ -1723,7 +1729,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') 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) Loading