Commit 6ccfd045 authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Fix reference citations

parent 782190fa
Loading
Loading
Loading
Loading
Loading
+14 −9
Changes for generateBaseline/postprocessing.py: 14 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -2968,6 +2968,18 @@ 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]

        def _text_run(text):
            run = OxmlElement('w:r')
            run.append(etree.fromstring(etree.tostring(rPr)))
            text_elem = OxmlElement('w:t')
            text_elem.text = text
            run.append(text_elem)
            return run

        begin_run = _fld_run('begin')
        instr_run = OxmlElement('w:r')
        instr = OxmlElement('w:instrText')
@@ -2978,17 +2990,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_run = OxmlElement('w:r')
        result_run.append(etree.fromstring(etree.tostring(rPr)))
        result_t = OxmlElement('w:t')
        if raw_text[:1].isspace() or raw_text[-1:].isspace():
            result_t.set('{http://www.w3.org/XML/1998/namespace}space', 'preserve')
        result_t.text = raw_text
        result_run.append(result_t)
        result_hyperlink.append(result_run)
        result_hyperlink.append(_text_run(inner_text))
        end_run = _fld_run('end')
        parent.remove(hyperlink)
        for offset, elem in enumerate((begin_run, instr_run, separate_run, result_hyperlink, end_run)):
        for offset, elem in enumerate((_text_run('['), begin_run, instr_run, separate_run, result_hyperlink, end_run, _text_run(']'))):
            parent.insert(index + offset, elem)
        field_counter += 1