Skip to content

Commit 1349a63

Browse files
committed
Add switch for parent type of li node to determine which mark to use
1 parent 6dea9ce commit 1349a63

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/html_parser.dart

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,13 +472,25 @@ class HtmlParser {
472472
),
473473
);
474474
case "li":
475+
String type = node.parent.localName; // Parent type; usually ol or ul
476+
EdgeInsets markPadding = EdgeInsets.symmetric(horizontal: 4.0);
477+
Widget mark;
478+
switch (type) {
479+
case "ul":
480+
mark = Container(child: Text('•'), padding: markPadding);
481+
break;
482+
case "ol": //TODO Use index as mark
483+
mark = Container(child: Text('•'), padding: markPadding);
484+
break;
485+
default: //Fallback to middle dot
486+
mark = Container(width: 0.0, height: 0.0);
487+
break;
488+
}
475489
return Container(
476490
width: width,
477491
child: Row(
478492
children: <Widget>[
479-
Container(
480-
child: Text('•'),
481-
padding: EdgeInsets.symmetric(horizontal: 4.0)),
493+
mark,
482494
Wrap(children: _parseNodeList(node.nodes))
483495
],
484496
),

0 commit comments

Comments
 (0)