Skip to content

Commit b45b827

Browse files
committed
Support padding and 'start' attribute for lists, support RTL direction for lists
1 parent 9327fe9 commit b45b827

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

lib/html_parser.dart

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -299,35 +299,35 @@ class HtmlParser extends StatelessWidget {
299299
newContext: newContext,
300300
style: tree.style,
301301
shrinkWrap: context.parser.shrinkWrap,
302-
child: Stack(
302+
child: Row(
303+
crossAxisAlignment: CrossAxisAlignment.start,
304+
mainAxisSize: MainAxisSize.min,
305+
textDirection: tree.style?.direction,
303306
children: [
304-
if (tree.style?.listStylePosition == ListStylePosition.OUTSIDE ||
305-
tree.style?.listStylePosition == null)
306-
PositionedDirectional(
307-
width: 30, //TODO derive this from list padding.
308-
start: 0,
309-
child: Text('${newContext.style.markerContent}\t',
310-
textAlign: TextAlign.right,
311-
style: newContext.style.generateTextStyle()),
312-
),
307+
tree.style?.listStylePosition == ListStylePosition.OUTSIDE ||
308+
tree.style?.listStylePosition == null ?
313309
Padding(
314-
padding: EdgeInsetsDirectional.only(
315-
start: 30), //TODO derive this from list padding.
316-
child: StyledText(
317-
textSpan: TextSpan(
318-
text: (tree.style?.listStylePosition ==
319-
ListStylePosition.INSIDE)
320-
? '${newContext.style.markerContent}\t'
321-
: null,
322-
children: tree.children
323-
?.map((tree) => parseTree(newContext, tree))
324-
?.toList() ??
325-
[],
326-
style: newContext.style.generateTextStyle(),
327-
),
328-
style: newContext.style,
329-
renderContext: context,
330-
),
310+
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),
311+
child: Text('${newContext.style.markerContent}\t',
312+
textAlign: TextAlign.right,
313+
style: newContext.style.generateTextStyle()),
314+
) : Container(height: 0, width: 0),
315+
Expanded(
316+
child: StyledText(
317+
textSpan: TextSpan(
318+
text: (tree.style?.listStylePosition ==
319+
ListStylePosition.INSIDE)
320+
? '${newContext.style.markerContent}\t'
321+
: null,
322+
children: tree.children
323+
?.map((tree) => parseTree(newContext, tree))
324+
?.toList() ??
325+
[],
326+
style: newContext.style.generateTextStyle(),
327+
),
328+
style: newContext.style,
329+
renderContext: context,
330+
)
331331
)
332332
],
333333
),
@@ -518,7 +518,7 @@ class HtmlParser extends StatelessWidget {
518518
static StyledElement _processListCharactersRecursive(
519519
StyledElement tree, ListQueue<Context<int>> olStack) {
520520
if (tree.name == 'ol') {
521-
olStack.add(Context(0));
521+
olStack.add(Context((tree.attributes['start'] != null ? int.tryParse(tree.attributes['start']) ?? 1 : 1) - 1));
522522
} else if (tree.style.display == Display.LIST_ITEM) {
523523
switch (tree.style.listStyleType) {
524524
case ListStyleType.DISC:

0 commit comments

Comments
 (0)