cleanTree static method

StyledElement cleanTree(
  1. StyledElement tree
)

cleanTree optimizes the StyledElement tree so all BlockElements are on the first level, redundant levels are collapsed, empty elements are removed, and specialty elements are processed.

Implementation

static StyledElement cleanTree(StyledElement tree) {
  tree = _processInternalWhitespace(tree);
  tree = _processInlineWhitespace(tree);
  tree = _removeEmptyElements(tree);
  tree = _processListCharacters(tree);
  tree = _processBeforesAndAfters(tree);
  tree = _collapseMargins(tree);
  tree = _processFontSize(tree);
  return tree;
}