File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -202,6 +202,9 @@ def _set_list_attributes(self, el):
202
202
list_elements = el .find_all ('numId' )
203
203
for li in list_elements :
204
204
parent = li .find_ancestor_with_tag ('p' )
205
+ # Deleted text in a list will have a numId but no ilvl.
206
+ if parent .find_first ('ilvl' ) is None :
207
+ continue
205
208
parent .is_list_item = True
206
209
parent .num_id = parent .find_first ('numId' ).attrib ['val' ]
207
210
parent .ilvl = parent .find_first ('ilvl' ).attrib ['val' ]
Original file line number Diff line number Diff line change 3
3
<w : pStyle w : val =" style0" />
4
4
{% if is_list %}
5
5
<w : numPr >
6
+ {% if ilvl != None %}
6
7
<w : ilvl w : val =" {{ ilvl }}" />
8
+ {% endif %}
9
+ {% if numId != None %}
7
10
<w : numId w : val =" {{ numId }}" />
11
+ {% endif %}
8
12
</w : numPr >
9
13
{% endif %}
10
14
</w : pPr >
Original file line number Diff line number Diff line change @@ -716,3 +716,30 @@ def get_xml(self):
716
716
717
717
xml = DXB .xml (body )
718
718
return xml
719
+
720
+
721
+ class MissingIlvl (_TranslationTestCase ):
722
+ expected_output = '''
723
+ <html><body>
724
+ <ol data-list-type="decimal">
725
+ <li>AAA<br/>
726
+ BBB
727
+ </li>
728
+ <li>CCC</li>
729
+ </ol>
730
+ </body></html>
731
+ '''
732
+
733
+ def get_xml (self ):
734
+ li_text = [
735
+ ('AAA' , 0 , 1 ),
736
+ ('BBB' , None , 1 ), # Because why not.
737
+ ('CCC' , 0 , 1 ),
738
+ ]
739
+ lis = ''
740
+ for text , ilvl , numId in li_text :
741
+ lis += DXB .li (text = text , ilvl = ilvl , numId = numId )
742
+ body = lis
743
+
744
+ xml = DXB .xml (body )
745
+ return xml
You can’t perform that action at this time.
0 commit comments