parseHtml function
List<SpanNode>
parseHtml(
- Text node, {
- ValueCallback? onError,
- WidgetVisitor? visitor,
- TextStyle? parentStyle,
parse m.Node
to h.Node
Implementation
List<SpanNode> parseHtml(
m.Text node, {
ValueCallback<dynamic>? onError,
WidgetVisitor? visitor,
TextStyle? parentStyle,
}) {
try {
final text =
node.textContent.replaceAll(RegExp(r'(\r?\n)|(\r?\t)|(\r)'), '');
if (!text.contains(htmlRep)) return [TextNode(text: node.text)];
h.DocumentFragment document = parseFragment(text);
return HtmlToSpanVisitor(visitor: visitor, parentStyle: parentStyle)
.toVisit(document.nodes.toList());
} catch (e) {
onError?.call(e);
return [TextNode(text: node.text)];
}
}