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:
|
// Inside of a list so we add some prefix text:
|
||||||
var text = node.text ?? '';
|
var text = node.text ?? '';
|
||||||
if (text == '\n') 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(
|
return LinkifySpan(
|
||||||
text: text,
|
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':
|
case 'blockquote':
|
||||||
return WidgetSpan(
|
return WidgetSpan(
|
||||||
child: Container(
|
child: Container(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue