Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-11-11 09:31:26 +08:00
parent 0f06de0047
commit d66a42a0aa
5 changed files with 47 additions and 44 deletions

View File

@@ -1,5 +1,3 @@
import 'package:html/parser.dart' show parse;
abstract class Em {
static final _exp = RegExp('<[^>]*>([^<]*)</[^>]*>');
@@ -19,7 +17,13 @@ abstract class Em {
},
onNonMatch: (String str) {
if (str != '') {
str = decodeHtmlEntities(str);
str = str
.replaceAll('&lt;', '<')
.replaceAll('&gt;', '>')
.replaceAll('&quot;', '"')
.replaceAll('&apos;', "'")
.replaceAll('&nbsp;', " ")
.replaceAll('&amp;', "&");
res.add((isEm: false, text: str));
}
return '';
@@ -27,8 +31,4 @@ abstract class Em {
);
return res;
}
static String decodeHtmlEntities(String title) {
return parse(title).body?.text ?? title;
}
}