Commit 73f33497 authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Fix for adding a breakline run for text belonging to a list element

parent 891b01fb
Loading
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1098,17 +1098,19 @@ def update_lists(docx_input, docx_output):

                            compact_style.set(f"{{{ns['w']}}}val", "B1")
                        else:
                            #print(f'Found text belonging to a numbered list item')
                            # Take the text from the paragraph
                            text = get_para_text(para)
                            print(f'Found text belonging to a numbered list item: {text}')
                            #  Insert it as new run to the previous paragraph. New run starting by <w:br/>
                            previous_para = para.getprevious()
                            if previous_para is not None:
                                new_run = OxmlElement('w:r')
                                new_run.append(OxmlElement('w:br'))
                                text_t = OxmlElement('w:t')
                                text_t.text = text
                                new_run.append(text_t)
                                break_run = OxmlElement('w:r')
                                break_run.append(OxmlElement('w:br'))
                                previous_para.append(break_run)
                                previous_para.append(new_run)
                            # Remove the original paragraph
                            para.getparent().remove(para)