@@ -352,11 +352,7 @@ class HtmlParser extends StatelessWidget {
352
352
tree.style.listStylePosition == ListStylePosition .OUTSIDE ?
353
353
Padding (
354
354
padding: tree.style.padding ?? EdgeInsets .only (left: tree.style.direction != TextDirection .rtl ? 10.0 : 0.0 , right: tree.style.direction == TextDirection .rtl ? 10.0 : 0.0 ),
355
- child: Text (
356
- "${newContext .style .markerContent }" ,
357
- textAlign: TextAlign .right,
358
- style: newContext.style.generateTextStyle ()
359
- ),
355
+ child: newContext.style.markerContent
360
356
) : Container (height: 0 , width: 0 ),
361
357
Text ("\t " , textAlign: TextAlign .right),
362
358
Expanded (
@@ -365,11 +361,10 @@ class HtmlParser extends StatelessWidget {
365
361
EdgeInsets .only (left: tree.style.direction != TextDirection .rtl ? 10.0 : 0.0 , right: tree.style.direction == TextDirection .rtl ? 10.0 : 0.0 ) : EdgeInsets .zero,
366
362
child: StyledText (
367
363
textSpan: TextSpan (
368
- text: (tree.style.listStylePosition ==
369
- ListStylePosition .INSIDE )
370
- ? '${newContext .style .markerContent }'
371
- : null ,
372
- children: getChildren (tree),
364
+ children: getChildren (tree)..insertAll (0 , tree.style.listStylePosition == ListStylePosition .INSIDE ?
365
+ [
366
+ WidgetSpan (alignment: PlaceholderAlignment .middle, child: newContext.style.markerContent ?? Container (height: 0 , width: 0 ))
367
+ ] : []),
373
368
style: newContext.style.generateTextStyle (),
374
369
),
375
370
style: newContext.style,
@@ -585,7 +580,10 @@ class HtmlParser extends StatelessWidget {
585
580
/// bullet all list items according to the [ListStyleType] they have been given.
586
581
static StyledElement _processListCharactersRecursive (
587
582
StyledElement tree, ListQueue <Context > olStack) {
588
- if (tree.name == 'ol' && tree.style.listStyleType != null ) {
583
+ if (tree.style.listStylePosition == null ) {
584
+ tree.style.listStylePosition = ListStylePosition .OUTSIDE ;
585
+ }
586
+ if (tree.name == 'ol' && tree.style.listStyleType != null && tree.style.listStyleType! .type == "marker" ) {
589
587
switch (tree.style.listStyleType! ) {
590
588
case ListStyleType .LOWER_LATIN :
591
589
case ListStyleType .LOWER_ALPHA :
@@ -605,23 +603,28 @@ class HtmlParser extends StatelessWidget {
605
603
olStack.add (Context <int >((tree.attributes['start' ] != null ? int .tryParse (tree.attributes['start' ] ?? "" ) ?? 1 : 1 ) - 1 ));
606
604
break ;
607
605
}
606
+ } else if (tree.style.display == Display .LIST_ITEM && tree.style.listStyleType != null && tree.style.listStyleType! .type == "widget" ) {
607
+ tree.style.markerContent = tree.style.listStyleType! .widget! ;
608
+ } else if (tree.style.display == Display .LIST_ITEM && tree.style.listStyleType != null && tree.style.listStyleType! .type == "image" ) {
609
+ tree.style.markerContent = Image .network (tree.style.listStyleType! .text);
608
610
} else if (tree.style.display == Display .LIST_ITEM && tree.style.listStyleType != null ) {
611
+ String marker = "" ;
609
612
switch (tree.style.listStyleType! ) {
610
613
case ListStyleType .CIRCLE :
611
- tree.style.markerContent = '○' ;
614
+ marker = '○' ;
612
615
break ;
613
616
case ListStyleType .SQUARE :
614
- tree.style.markerContent = '■' ;
617
+ marker = '■' ;
615
618
break ;
616
619
case ListStyleType .DISC :
617
- tree.style.markerContent = '•' ;
620
+ marker = '•' ;
618
621
break ;
619
622
case ListStyleType .DECIMAL :
620
623
if (olStack.isEmpty) {
621
624
olStack.add (Context <int >((tree.attributes['start' ] != null ? int .tryParse (tree.attributes['start' ] ?? "" ) ?? 1 : 1 ) - 1 ));
622
625
}
623
626
olStack.last.data += 1 ;
624
- tree.style.markerContent = '${olStack .last .data }.' ;
627
+ marker = '${olStack .last .data }.' ;
625
628
break ;
626
629
case ListStyleType .LOWER_LATIN :
627
630
case ListStyleType .LOWER_ALPHA :
@@ -636,7 +639,7 @@ class HtmlParser extends StatelessWidget {
636
639
}
637
640
}
638
641
}
639
- tree.style.markerContent = olStack.last.data.toString () + "." ;
642
+ marker = olStack.last.data.toString () + "." ;
640
643
olStack.last.data = olStack.last.data.toString ().nextLetter ();
641
644
break ;
642
645
case ListStyleType .UPPER_LATIN :
@@ -652,7 +655,7 @@ class HtmlParser extends StatelessWidget {
652
655
}
653
656
}
654
657
}
655
- tree.style.markerContent = olStack.last.data.toString ().toUpperCase () + "." ;
658
+ marker = olStack.last.data.toString ().toUpperCase () + "." ;
656
659
olStack.last.data = olStack.last.data.toString ().nextLetter ();
657
660
break ;
658
661
case ListStyleType .LOWER_ROMAN :
@@ -661,9 +664,9 @@ class HtmlParser extends StatelessWidget {
661
664
}
662
665
olStack.last.data += 1 ;
663
666
if (olStack.last.data <= 0 ) {
664
- tree.style.markerContent = '${olStack .last .data }.' ;
667
+ marker = '${olStack .last .data }.' ;
665
668
} else {
666
- tree.style.markerContent = (olStack.last.data as int ).toRomanNumeralString ()! .toLowerCase () + "." ;
669
+ marker = (olStack.last.data as int ).toRomanNumeralString ()! .toLowerCase () + "." ;
667
670
}
668
671
break ;
669
672
case ListStyleType .UPPER_ROMAN :
@@ -672,12 +675,16 @@ class HtmlParser extends StatelessWidget {
672
675
}
673
676
olStack.last.data += 1 ;
674
677
if (olStack.last.data <= 0 ) {
675
- tree.style.markerContent = '${olStack .last .data }.' ;
678
+ marker = '${olStack .last .data }.' ;
676
679
} else {
677
- tree.style.markerContent = (olStack.last.data as int ).toRomanNumeralString ()! + "." ;
680
+ marker = (olStack.last.data as int ).toRomanNumeralString ()! + "." ;
678
681
}
679
682
break ;
680
683
}
684
+ tree.style.markerContent = Text (
685
+ marker,
686
+ textAlign: TextAlign .right,
687
+ );
681
688
}
682
689
683
690
tree.children.forEach ((e) => _processListCharactersRecursive (e, olStack));
0 commit comments