@@ -420,11 +420,7 @@ class HtmlParser extends StatelessWidget {
420420 tree.style.listStylePosition == ListStylePosition .OUTSIDE ?
421421 Padding (
422422 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 ),
423- child: Text (
424- "${newContext .style .markerContent }" ,
425- textAlign: TextAlign .right,
426- style: newContext.style.generateTextStyle ()
427- ),
423+ child: newContext.style.markerContent
428424 ) : Container (height: 0 , width: 0 ),
429425 Text ("\t " , textAlign: TextAlign .right),
430426 Expanded (
@@ -433,11 +429,10 @@ class HtmlParser extends StatelessWidget {
433429 EdgeInsets .only (left: tree.style.direction != TextDirection .rtl ? 10.0 : 0.0 , right: tree.style.direction == TextDirection .rtl ? 10.0 : 0.0 ) : EdgeInsets .zero,
434430 child: StyledText (
435431 textSpan: TextSpan (
436- text: (tree.style.listStylePosition ==
437- ListStylePosition .INSIDE )
438- ? '${newContext .style .markerContent }'
439- : null ,
440- children: getChildren (tree),
432+ children: getChildren (tree)..insertAll (0 , tree.style.listStylePosition == ListStylePosition .INSIDE ?
433+ [
434+ WidgetSpan (alignment: PlaceholderAlignment .middle, child: newContext.style.markerContent ?? Container (height: 0 , width: 0 ))
435+ ] : []),
441436 style: newContext.style.generateTextStyle (),
442437 ),
443438 style: newContext.style,
@@ -451,12 +446,12 @@ class HtmlParser extends StatelessWidget {
451446 );
452447 } else if (tree is ReplacedElement ) {
453448 if (tree is TextContentElement ) {
454- return TextSpan (text: tree.text);
449+ return TextSpan (text: tree.text? . transformed (tree.style.textTransform) );
455450 } else {
456451 return WidgetSpan (
457452 alignment: tree.alignment,
458453 baseline: TextBaseline .alphabetic,
459- child: tree.toWidget (context )! ,
454+ child: tree.toWidget (newContext )! ,
460455 );
461456 }
462457 } else if (tree is InteractableElement ) {
@@ -708,7 +703,10 @@ class HtmlParser extends StatelessWidget {
708703 /// bullet all list items according to the [ListStyleType] they have been given.
709704 static StyledElement _processListCharactersRecursive (
710705 StyledElement tree, ListQueue <Context > olStack) {
711- if (tree.name == 'ol' && tree.style.listStyleType != null ) {
706+ if (tree.style.listStylePosition == null ) {
707+ tree.style.listStylePosition = ListStylePosition .OUTSIDE ;
708+ }
709+ if (tree.name == 'ol' && tree.style.listStyleType != null && tree.style.listStyleType! .type == "marker" ) {
712710 switch (tree.style.listStyleType! ) {
713711 case ListStyleType .LOWER_LATIN :
714712 case ListStyleType .LOWER_ALPHA :
@@ -728,26 +726,31 @@ class HtmlParser extends StatelessWidget {
728726 olStack.add (Context <int >((tree.attributes['start' ] != null ? int .tryParse (tree.attributes['start' ] ?? "" ) ?? 1 : 1 ) - 1 ));
729727 break ;
730728 }
729+ } else if (tree.style.display == Display .LIST_ITEM && tree.style.listStyleType != null && tree.style.listStyleType! .type == "widget" ) {
730+ tree.style.markerContent = tree.style.listStyleType! .widget! ;
731+ } else if (tree.style.display == Display .LIST_ITEM && tree.style.listStyleType != null && tree.style.listStyleType! .type == "image" ) {
732+ tree.style.markerContent = Image .network (tree.style.listStyleType! .text);
731733 } else if (tree.style.display == Display .LIST_ITEM && tree.style.listStyleType != null ) {
734+ String marker = "" ;
732735 switch (tree.style.listStyleType! ) {
733736 case ListStyleType .NONE :
734737 tree.style.markerContent = '' ;
735738 break ;
736739 case ListStyleType .CIRCLE :
737- tree.style.markerContent = '○' ;
740+ marker = '○' ;
738741 break ;
739742 case ListStyleType .SQUARE :
740- tree.style.markerContent = '■' ;
743+ marker = '■' ;
741744 break ;
742745 case ListStyleType .DISC :
743- tree.style.markerContent = '•' ;
746+ marker = '•' ;
744747 break ;
745748 case ListStyleType .DECIMAL :
746749 if (olStack.isEmpty) {
747750 olStack.add (Context <int >((tree.attributes['start' ] != null ? int .tryParse (tree.attributes['start' ] ?? "" ) ?? 1 : 1 ) - 1 ));
748751 }
749752 olStack.last.data += 1 ;
750- tree.style.markerContent = '${olStack .last .data }.' ;
753+ marker = '${olStack .last .data }.' ;
751754 break ;
752755 case ListStyleType .LOWER_LATIN :
753756 case ListStyleType .LOWER_ALPHA :
@@ -762,7 +765,7 @@ class HtmlParser extends StatelessWidget {
762765 }
763766 }
764767 }
765- tree.style.markerContent = olStack.last.data.toString () + "." ;
768+ marker = olStack.last.data.toString () + "." ;
766769 olStack.last.data = olStack.last.data.toString ().nextLetter ();
767770 break ;
768771 case ListStyleType .UPPER_LATIN :
@@ -778,7 +781,7 @@ class HtmlParser extends StatelessWidget {
778781 }
779782 }
780783 }
781- tree.style.markerContent = olStack.last.data.toString ().toUpperCase () + "." ;
784+ marker = olStack.last.data.toString ().toUpperCase () + "." ;
782785 olStack.last.data = olStack.last.data.toString ().nextLetter ();
783786 break ;
784787 case ListStyleType .LOWER_ROMAN :
@@ -787,9 +790,9 @@ class HtmlParser extends StatelessWidget {
787790 }
788791 olStack.last.data += 1 ;
789792 if (olStack.last.data <= 0 ) {
790- tree.style.markerContent = '${olStack .last .data }.' ;
793+ marker = '${olStack .last .data }.' ;
791794 } else {
792- tree.style.markerContent = (olStack.last.data as int ).toRomanNumeralString ()! .toLowerCase () + "." ;
795+ marker = (olStack.last.data as int ).toRomanNumeralString ()! .toLowerCase () + "." ;
793796 }
794797 break ;
795798 case ListStyleType .UPPER_ROMAN :
@@ -798,12 +801,16 @@ class HtmlParser extends StatelessWidget {
798801 }
799802 olStack.last.data += 1 ;
800803 if (olStack.last.data <= 0 ) {
801- tree.style.markerContent = '${olStack .last .data }.' ;
804+ marker = '${olStack .last .data }.' ;
802805 } else {
803- tree.style.markerContent = (olStack.last.data as int ).toRomanNumeralString ()! + "." ;
806+ marker = (olStack.last.data as int ).toRomanNumeralString ()! + "." ;
804807 }
805808 break ;
806809 }
810+ tree.style.markerContent = Text (
811+ marker,
812+ textAlign: TextAlign .right,
813+ );
807814 }
808815
809816 tree.children.forEach ((e) => _processListCharactersRecursive (e, olStack));
0 commit comments