mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-17 23:56:13 +08:00
opt: regTitle
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import 'package:html/parser.dart' show parse;
|
||||||
|
|
||||||
class Em {
|
class Em {
|
||||||
static regCate(String origin) {
|
static regCate(String origin) {
|
||||||
String str = origin;
|
String str = origin;
|
||||||
@@ -12,32 +14,37 @@ class Em {
|
|||||||
static regTitle(String origin) {
|
static regTitle(String origin) {
|
||||||
RegExp exp = RegExp('<[^>]*>([^<]*)</[^>]*>');
|
RegExp exp = RegExp('<[^>]*>([^<]*)</[^>]*>');
|
||||||
List res = [];
|
List res = [];
|
||||||
origin.splitMapJoin(exp, onMatch: (Match match) {
|
origin.splitMapJoin(
|
||||||
String matchStr = match[0]!;
|
exp,
|
||||||
Map map = {'type': 'em', 'text': regCate(matchStr)};
|
onMatch: (Match match) {
|
||||||
res.add(map);
|
String matchStr = match[0]!;
|
||||||
return regCate(matchStr);
|
Map map = {'type': 'em', 'text': regCate(matchStr)};
|
||||||
}, onNonMatch: (String str) {
|
|
||||||
if (str != '') {
|
|
||||||
str = decodeHtmlEntities(str);
|
|
||||||
Map map = {'type': 'text', 'text': str};
|
|
||||||
res.add(map);
|
res.add(map);
|
||||||
}
|
return regCate(matchStr);
|
||||||
return str;
|
},
|
||||||
});
|
onNonMatch: (String str) {
|
||||||
|
if (str != '') {
|
||||||
|
str = parse(str).body?.text ?? str;
|
||||||
|
Map map = {'type': 'text', 'text': str};
|
||||||
|
res.add(map);
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
},
|
||||||
|
);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static String decodeHtmlEntities(String title) {
|
static String decodeHtmlEntities(String title) {
|
||||||
return title
|
return parse(title).body?.text ?? title;
|
||||||
.replaceAll('<', '<')
|
// return title
|
||||||
.replaceAll('>', '>')
|
// .replaceAll('<', '<')
|
||||||
.replaceAll('"', '"')
|
// .replaceAll('>', '>')
|
||||||
.replaceAll(''', "'")
|
// .replaceAll('"', '"')
|
||||||
.replaceAll('"', '"')
|
// .replaceAll(''', "'")
|
||||||
.replaceAll(''', "'")
|
// .replaceAll('"', '"')
|
||||||
.replaceAll(' ', " ")
|
// .replaceAll(''', "'")
|
||||||
.replaceAll('&', "&")
|
// .replaceAll(' ', " ")
|
||||||
.replaceAll(''', "'");
|
// .replaceAll('&', "&")
|
||||||
|
// .replaceAll(''', "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user