Loading generateBaseline/postprocessing.py +7 −5 Changes for generateBaseline/postprocessing.py: 7 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -2983,9 +2983,11 @@ def update_references_style(docx_input, docx_output): if parent is None: continue index = list(parent).index(hyperlink) inner_text = raw_text.strip() if inner_text.startswith('[') and inner_text.endswith(']'): inner_text = inner_text[1:-1] # The REF_ bookmark from update_references already includes the square # brackets. Keep them inside the field result. Brackets outside the # field stay put when Word updates fields, and the bookmark text is # written again, which produces [[i.1]]. result_text = raw_text.strip() def _text_run(text): run = OxmlElement('w:r') Loading @@ -3005,10 +3007,10 @@ def update_references_style(docx_input, docx_output): result_hyperlink = OxmlElement('w:hyperlink') result_hyperlink.set(qn('w:anchor'), ref_name) result_hyperlink.set(qn('w:history'), '1') result_hyperlink.append(_text_run(inner_text)) result_hyperlink.append(_text_run(result_text)) end_run = _fld_run('end') parent.remove(hyperlink) for offset, elem in enumerate((_text_run('['), begin_run, instr_run, separate_run, result_hyperlink, end_run, _text_run(']'))): for offset, elem in enumerate((begin_run, instr_run, separate_run, result_hyperlink, end_run)): parent.insert(index + offset, elem) field_counter += 1 Loading Loading
generateBaseline/postprocessing.py +7 −5 Changes for generateBaseline/postprocessing.py: 7 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -2983,9 +2983,11 @@ def update_references_style(docx_input, docx_output): if parent is None: continue index = list(parent).index(hyperlink) inner_text = raw_text.strip() if inner_text.startswith('[') and inner_text.endswith(']'): inner_text = inner_text[1:-1] # The REF_ bookmark from update_references already includes the square # brackets. Keep them inside the field result. Brackets outside the # field stay put when Word updates fields, and the bookmark text is # written again, which produces [[i.1]]. result_text = raw_text.strip() def _text_run(text): run = OxmlElement('w:r') Loading @@ -3005,10 +3007,10 @@ def update_references_style(docx_input, docx_output): result_hyperlink = OxmlElement('w:hyperlink') result_hyperlink.set(qn('w:anchor'), ref_name) result_hyperlink.set(qn('w:history'), '1') result_hyperlink.append(_text_run(inner_text)) result_hyperlink.append(_text_run(result_text)) end_run = _fld_run('end') parent.remove(hyperlink) for offset, elem in enumerate((_text_run('['), begin_run, instr_run, separate_run, result_hyperlink, end_run, _text_run(']'))): for offset, elem in enumerate((begin_run, instr_run, separate_run, result_hyperlink, end_run)): parent.insert(index + offset, elem) field_counter += 1 Loading