chore: Follow up html lists
This commit is contained in:
parent
6cdfced81f
commit
49453e3eb3
1 changed files with 28 additions and 16 deletions
|
|
@ -131,22 +131,6 @@ class HtmlMessage extends StatelessWidget {
|
|||
// Inside of a list so we add some prefix text:
|
||||
var text = node.text ?? '';
|
||||
if (text == '\n') text = '';
|
||||
if (node.parent?.localName == 'li' &&
|
||||
node.parent?.nodes.indexOf(node) == 0) {
|
||||
if (node.parent?.parent?.localName == 'ul') {
|
||||
text = '• $text';
|
||||
}
|
||||
if (node.parent?.parent?.localName == 'ol') {
|
||||
final start =
|
||||
int.tryParse(node.parent?.parent?.attributes['start'] ?? '1') ??
|
||||
1;
|
||||
text =
|
||||
'${(node.parent?.parent?.nodes.indexOf(node.parent) ?? 0) + start}. $text';
|
||||
}
|
||||
if (node.parent?.parent?.parent?.localName == 'li') {
|
||||
text = ' $text';
|
||||
}
|
||||
}
|
||||
|
||||
return LinkifySpan(
|
||||
text: text,
|
||||
|
|
@ -216,6 +200,34 @@ class HtmlMessage extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
);
|
||||
case 'li':
|
||||
if (!{'ol', 'ul'}.contains(node.parent?.localName)) {
|
||||
continue block;
|
||||
}
|
||||
return WidgetSpan(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: fontSize),
|
||||
child: Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
if (node.parent?.localName == 'ul')
|
||||
const TextSpan(text: '• '),
|
||||
if (node.parent?.localName == 'ol')
|
||||
TextSpan(
|
||||
text:
|
||||
'${(node.parent?.nodes.indexOf(node) ?? 0) + (int.tryParse(node.parent?.attributes['start'] ?? '1') ?? 1)}. ',
|
||||
),
|
||||
..._renderWithLineBreaks(
|
||||
node.nodes,
|
||||
context,
|
||||
depth: depth,
|
||||
),
|
||||
],
|
||||
style: TextStyle(fontSize: fontSize, color: textColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
case 'blockquote':
|
||||
return WidgetSpan(
|
||||
child: Container(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue