@@ -295,40 +295,53 @@ class HtmlParser extends StatelessWidget {
295295 ),
296296 );
297297 } else if (tree.style? .display == Display .LIST_ITEM ) {
298+ List <InlineSpan > getChildren (StyledElement tree) {
299+ InlineSpan tabSpan = WidgetSpan (child: Text ("\t " , textAlign: TextAlign .right));
300+ List <InlineSpan > children = tree.children? .map ((tree) => parseTree (newContext, tree))? .toList () ?? [];
301+ if (tree.style? .listStylePosition == ListStylePosition .INSIDE ) {
302+ children.insert (0 , tabSpan);
303+ }
304+ return children;
305+ }
306+
298307 return WidgetSpan (
299308 child: ContainerSpan (
300309 newContext: newContext,
301310 style: tree.style,
302311 shrinkWrap: context.parser.shrinkWrap,
303- child: Stack (
312+ child: Row (
313+ crossAxisAlignment: CrossAxisAlignment .start,
314+ mainAxisSize: MainAxisSize .min,
315+ textDirection: tree.style? .direction,
304316 children: [
305- if (tree.style? .listStylePosition == ListStylePosition .OUTSIDE ||
306- tree.style? .listStylePosition == null )
307- PositionedDirectional (
308- width: 30 , //TODO derive this from list padding.
309- start: 0 ,
310- child: Text ('${newContext .style .markerContent }\t ' ,
311- textAlign: TextAlign .right,
312- style: newContext.style.generateTextStyle ()),
313- ),
317+ tree.style? .listStylePosition == ListStylePosition .OUTSIDE ||
318+ tree.style? .listStylePosition == null ?
314319 Padding (
315- padding: EdgeInsetsDirectional .only (
316- start: 30 ), //TODO derive this from list padding.
317- child: StyledText (
318- textSpan: TextSpan (
319- text: (tree.style? .listStylePosition ==
320- ListStylePosition .INSIDE )
321- ? '${newContext .style .markerContent }\t '
322- : null ,
323- children: tree.children
324- ? .map ((tree) => parseTree (newContext, tree))
325- ? .toList () ??
326- [],
327- style: newContext.style.generateTextStyle (),
328- ),
329- style: newContext.style,
330- renderContext: context,
320+ 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 ),
321+ child: Text (
322+ newContext.style.markerContent,
323+ textAlign: TextAlign .right,
324+ style: newContext.style.generateTextStyle ()
331325 ),
326+ ) : Container (height: 0 , width: 0 ),
327+ Text ("\t " , textAlign: TextAlign .right),
328+ Expanded (
329+ child: Padding (
330+ padding: tree.style? .listStylePosition == ListStylePosition .INSIDE ?
331+ EdgeInsets .only (left: tree.style? .direction != TextDirection .rtl ? 10.0 : 0.0 , right: tree.style? .direction == TextDirection .rtl ? 10.0 : 0.0 ) : EdgeInsets .zero,
332+ child: StyledText (
333+ textSpan: TextSpan (
334+ text: (tree.style? .listStylePosition ==
335+ ListStylePosition .INSIDE )
336+ ? '${newContext .style .markerContent }'
337+ : null ,
338+ children: getChildren (tree),
339+ style: newContext.style.generateTextStyle (),
340+ ),
341+ style: newContext.style,
342+ renderContext: context,
343+ )
344+ )
332345 )
333346 ],
334347 ),
@@ -519,7 +532,7 @@ class HtmlParser extends StatelessWidget {
519532 static StyledElement _processListCharactersRecursive (
520533 StyledElement tree, ListQueue <Context <int >> olStack) {
521534 if (tree.name == 'ol' ) {
522- olStack.add (Context (0 ));
535+ olStack.add (Context ((tree.attributes[ 'start' ] != null ? int . tryParse (tree.attributes[ 'start' ]) ?? 1 : 1 ) - 1 ));
523536 } else if (tree.style.display == Display .LIST_ITEM ) {
524537 switch (tree.style.listStyleType) {
525538 case ListStyleType .DISC :
0 commit comments