isPreformatted method

bool isPreformatted(
  1. Node node
)

Whether node sits inside a <pre> element, where the HTML specification preserves whitespace.

Implementation

bool isPreformatted(dom.Node node) {
  for (var parent = node.parent; parent != null; parent = parent.parent) {
    if (parent.localName == 'pre') return true;
  }
  return false;
}