chore: Follow up html rendering

This commit is contained in:
Christian Kußowski 2025-12-02 11:06:41 +01:00
commit 89a167dc57
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652

View file

@ -156,6 +156,11 @@ class HtmlMessage extends StatelessWidget {
// We must not render elements nested more than 100 elements deep: // We must not render elements nested more than 100 elements deep:
if (depth >= 100) return const TextSpan(); if (depth >= 100) return const TextSpan();
if (node is dom.Element &&
ignoredHtmlTags.contains(node.localName?.toLowerCase())) {
return const TextSpan();
}
// This is a text node or not permitted node, so we render it as text: // This is a text node or not permitted node, so we render it as text:
if (node is! dom.Element || !allowedHtmlTags.contains(node.localName)) { if (node is! dom.Element || !allowedHtmlTags.contains(node.localName)) {
var text = node.text ?? ''; var text = node.text ?? '';
@ -170,8 +175,6 @@ class HtmlMessage extends StatelessWidget {
); );
} }
if (ignoredHtmlTags.contains(node.localName)) return const TextSpan();
switch (node.localName) { switch (node.localName) {
case 'br': case 'br':
return const TextSpan(text: '\n'); return const TextSpan(text: '\n');
@ -260,13 +263,15 @@ class HtmlMessage extends StatelessWidget {
child: Text.rich( child: Text.rich(
TextSpan( TextSpan(
children: [ children: [
if (node.parent?.localName == 'ul') if (!isCheckbox) ...[
const TextSpan(text: ''), if (node.parent?.localName == 'ul')
if (node.parent?.localName == 'ol') const TextSpan(text: ''),
TextSpan( if (node.parent?.localName == 'ol')
text: TextSpan(
'${(node.parent?.nodes.whereType<dom.Element>().toList().indexOf(node) ?? 0) + (int.tryParse(node.parent?.attributes['start'] ?? '1') ?? 1)}. ', text:
), '${(node.parent?.nodes.whereType<dom.Element>().toList().indexOf(node) ?? 0) + (int.tryParse(node.parent?.attributes['start'] ?? '1') ?? 1)}. ',
),
],
if (node.className == 'task-list-item') if (node.className == 'task-list-item')
WidgetSpan( WidgetSpan(
child: Padding( child: Padding(