writeTextNodeAsHtml function
Serialize text node according to: www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#html-fragment-serialization-algorithm
Implementation
void writeTextNodeAsHtml(StringBuffer str, Text node) {
// Don't escape text for certain elements, notably <script>.
final parent = node.parentNode;
if (parent is Element) {
final tag = parent.localName;
if (rcdataElements.contains(tag) || tag == 'plaintext') {
str.write(node.data);
return;
}
}
str.write(htmlSerializeEscape(node.data));
}