textHandler function
Implementation
Object? textHandler(Parser parser, Element source, {required String selectr}) {
List<String> results = [];
if (parser.multiple) {
List<Element> selector = source.querySelectorAll(selectr);
if (selector.isNotEmpty) {
for (final s in selector) {
if (s.innerHtml.contains("<br>")) {
String outerHtml = s.outerHtml.replaceAll("<br>", " ");
Document outerDom = parse(outerHtml);
results.add(outerDom.body!.text.toString().trim());
} else {
results.add(s.text.toString().trim());
}
}
results.removeWhere((value) => value == "");
return results;
}
} else {
Element? selector = source.querySelector(selectr);
if (selector != null) {
if (selector.text.toString().trim() != "") {
return selector.text.toString().trim();
}
}
}
return null;
}