diff --git a/lib/html_parser.dart b/lib/html_parser.dart index be655f98da..a34d6571d3 100644 --- a/lib/html_parser.dart +++ b/lib/html_parser.dart @@ -267,19 +267,24 @@ class HtmlParser extends StatelessWidget { style: tree.style, shrinkWrap: context.parser.shrinkWrap, child: Stack( - children: [ - PositionedDirectional( - width: 30, //TODO derive this from list padding. - start: 0, - child: Text('${newContext.style.markerContent}\t', - textAlign: TextAlign.end, - style: newContext.style.generateTextStyle()), - ), + children: [ + if (tree.style?.listStylePosition == ListStylePosition.OUTSIDE || tree.style?.listStylePosition == null) + PositionedDirectional( + width: 30, //TODO derive this from list padding. + start: 0, + child: Text('${newContext.style.markerContent}\t', + textAlign: TextAlign.right, + style: newContext.style.generateTextStyle()), + ), Padding( padding: EdgeInsetsDirectional.only( start: 30), //TODO derive this from list padding. child: StyledText( textSpan: TextSpan( + text: (tree.style?.listStylePosition == + ListStylePosition.INSIDE) + ? '${newContext.style.markerContent}\t' + : null, children: tree.children ?.map((tree) => parseTree(newContext, tree)) ?.toList() ?? diff --git a/lib/style.dart b/lib/style.dart index 1ee93541ae..4a7c454a8c 100644 --- a/lib/style.dart +++ b/lib/style.dart @@ -77,6 +77,12 @@ class Style { /// Default: ListStyleType.DISC ListStyleType listStyleType; + /// CSS attribute "`list-style-position`" + /// + /// Inherited: yes, + /// Default: ListStylePosition.OUTSIDE + ListStylePosition listStylePosition; + /// CSS attribute "`padding`" /// /// Inherited: no, @@ -183,6 +189,7 @@ class Style { this.lineHeight, this.letterSpacing, this.listStyleType, + this.listStylePosition, this.padding, this.margin, this.textAlign, @@ -251,6 +258,7 @@ class Style { lineHeight: other.lineHeight, letterSpacing: other.letterSpacing, listStyleType: other.listStyleType, + listStylePosition: other.listStylePosition, padding: other.padding, //TODO merge EdgeInsets margin: other.margin, @@ -288,6 +296,7 @@ class Style { fontWeight: child.fontWeight ?? fontWeight, letterSpacing: child.letterSpacing ?? letterSpacing, listStyleType: child.listStyleType ?? listStyleType, + listStylePosition: child.listStylePosition ?? listStylePosition, textAlign: child.textAlign ?? textAlign, textShadow: child.textShadow ?? textShadow, whiteSpace: child.whiteSpace ?? whiteSpace, @@ -309,6 +318,7 @@ class Style { double lineHeight, double letterSpacing, ListStyleType listStyleType, + ListStylePosition listStylePosition, EdgeInsets padding, EdgeInsets margin, TextAlign textAlign, @@ -341,6 +351,7 @@ class Style { lineHeight: lineHeight ?? this.lineHeight, letterSpacing: letterSpacing ?? this.letterSpacing, listStyleType: listStyleType ?? this.listStyleType, + listStylePosition: listStylePosition ?? this.listStylePosition, padding: padding ?? this.padding, margin: margin ?? this.margin, textAlign: textAlign ?? this.textAlign, @@ -421,6 +432,11 @@ enum ListStyleType { DECIMAL, } +enum ListStylePosition { + OUTSIDE, + INSIDE, +} + enum VerticalAlign { BASELINE, SUB,