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

Fix for lists

parent 6402d667
Loading
Loading
Loading
Loading
Loading
+8 −5
Original line number Original line Diff line number Diff line
@@ -1016,17 +1016,19 @@ def update_unnumbered_lists(docx_input, docx_output):
                compact_style = compact_style_elems[0]
                compact_style = compact_style_elems[0]
            else:
            else:
                compact_style = OxmlElement('w:pStyle')
                compact_style = OxmlElement('w:pStyle')
                pPr.insert(0, compact_style)
           # Check if it is a numbered list and get the format
           # Check if it is a numbered list and get the format
            is_numbered, num_format = is_numbered_list(para, numbering_root)
            is_numbered, num_format = is_numbered_list(para, numbering_root)
            if is_numbered:  # is_numbered is True if numbered, False if unnumbered, None if cannot determine
            if is_numbered:  # is_numbered is True if numbered, False if unnumbered, None if cannot determine
                pStyle = OxmlElement('w:pStyle')
                #pStyle = OxmlElement('w:pStyle')
                # If format is decimal (numbers), use BN; otherwise use BL
                # If format is decimal (numbers), use BN; otherwise use BL
                if num_format == 'decimal':
                if num_format == 'decimal':
                    pStyle.set(f"{{{ns['w']}}}val", "BN")
                    compact_style.set(f"{{{ns['w']}}}val", "BN")
                else:
                else:
                    pStyle.set(f"{{{ns['w']}}}val", "BL")
                    compact_style.set(f"{{{ns['w']}}}val", "BL")
                pPr.append(pStyle)
                pPr.insert(0, compact_style)
                # Remove numId from numPr
                numPr = pPr.xpath('./w:numPr', namespaces=ns)[0]
                numPr.remove(numPr.xpath('./w:numId', namespaces=ns)[0])
                counter_numbered += 1
                counter_numbered += 1
            else:                
            else:                
                if para.xpath('./w:pPr/w:numPr/w:ilvl[@w:val="0"]', namespaces=ns):
                if para.xpath('./w:pPr/w:numPr/w:ilvl[@w:val="0"]', namespaces=ns):
@@ -1059,6 +1061,7 @@ def update_unnumbered_lists(docx_input, docx_output):
                    numPr = pPr.xpath('./w:numPr', namespaces=ns)[0]
                    numPr = pPr.xpath('./w:numPr', namespaces=ns)[0]
                    pPr.remove(numPr)
                    pPr.remove(numPr)
                    counter_b3 += 1
                    counter_b3 += 1
                pPr.insert(0, compact_style)
                counter_compact += 1
                counter_compact += 1
                continue
                continue