Loading generateBaseline/postprocessing.py +9 Changes for generateBaseline/postprocessing.py: 9 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -2301,6 +2301,13 @@ def update_abbreviations(docx_input, docx_output): root = etree.fromstring(xml_data) counter = 0 def _run_text(run): parts = [] for text_elem in run.xpath('.//w:t', namespaces=ns): if text_elem.text: parts.append(text_elem.text) return ''.join(parts) # Find all paragraphs with BodyText style paragraphs_to_process = root.xpath('.//w:p[w:pPr/w:pStyle[@w:val="BodyText"]]', namespaces=ns) for para in paragraphs_to_process: Loading Loading @@ -2343,6 +2350,8 @@ def update_abbreviations(docx_input, docx_output): # Option 2: abbreviation (in a verbatim run) followed by definition (in the remaining runs of the paragraph) separated by one or more spaces # Take all remaining runs of the paragraph as they are, except the verbatim run remaining_runs = [run for run in para.xpath('./w:r', namespaces=ns) if run != verbatim_run] while remaining_runs and _run_text(remaining_runs[0]).isspace(): remaining_runs.pop(0) abbreviation = full_text_in_verbatim_run.strip() option2_definition = True #definition = ''.join([run.xpath('.//w:t/text()', namespaces=ns)[0].text for run in remaining_runs]).strip() Loading Loading
generateBaseline/postprocessing.py +9 Changes for generateBaseline/postprocessing.py: 9 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -2301,6 +2301,13 @@ def update_abbreviations(docx_input, docx_output): root = etree.fromstring(xml_data) counter = 0 def _run_text(run): parts = [] for text_elem in run.xpath('.//w:t', namespaces=ns): if text_elem.text: parts.append(text_elem.text) return ''.join(parts) # Find all paragraphs with BodyText style paragraphs_to_process = root.xpath('.//w:p[w:pPr/w:pStyle[@w:val="BodyText"]]', namespaces=ns) for para in paragraphs_to_process: Loading Loading @@ -2343,6 +2350,8 @@ def update_abbreviations(docx_input, docx_output): # Option 2: abbreviation (in a verbatim run) followed by definition (in the remaining runs of the paragraph) separated by one or more spaces # Take all remaining runs of the paragraph as they are, except the verbatim run remaining_runs = [run for run in para.xpath('./w:r', namespaces=ns) if run != verbatim_run] while remaining_runs and _run_text(remaining_runs[0]).isspace(): remaining_runs.pop(0) abbreviation = full_text_in_verbatim_run.strip() option2_definition = True #definition = ''.join([run.xpath('.//w:t/text()', namespaces=ns)[0].text for run in remaining_runs]).strip() Loading