@@ -426,10 +426,29 @@ def parse_list(self, el, text):
426
426
return self .parse_table_cell_contents (el , parsed )
427
427
return parsed
428
428
429
+ def _build_list (self , el , text ):
430
+ # Get the list style for the pending list.
431
+ lst_style = self .get_list_style (
432
+ el .num_id ,
433
+ el .ilvl ,
434
+ )
435
+
436
+ parsed = text
437
+ # Create the actual list and return it.
438
+ if lst_style == 'bullet' :
439
+ return self .unordered_list (parsed )
440
+ else :
441
+ return self .ordered_list (
442
+ parsed ,
443
+ lst_style ,
444
+ )
445
+
429
446
def _parse_list (self , el , text ):
430
447
parsed = self .parse_list_item (el , text )
431
448
num_id = el .num_id
432
449
ilvl = el .ilvl
450
+ if el .is_last_list_item_in_root :
451
+ return self ._build_list (el , parsed )
433
452
next_el = el .next
434
453
435
454
def is_same_list (next_el , num_id , ilvl ):
@@ -488,20 +507,7 @@ def should_parse_last_el(last_el, first_el):
488
507
if parsed == '' :
489
508
return parsed
490
509
491
- # Get the list style for the pending list.
492
- lst_style = self .get_list_style (
493
- el .num_id ,
494
- el .ilvl ,
495
- )
496
-
497
- # Create the actual list and return it.
498
- if lst_style == 'bullet' :
499
- return self .unordered_list (parsed )
500
- else :
501
- return self .ordered_list (
502
- parsed ,
503
- lst_style ,
504
- )
510
+ return self ._build_list (el , parsed )
505
511
506
512
def parse_p (self , el , text ):
507
513
if text == '' :
0 commit comments