lexDomTree static method

StyledElement lexDomTree(
  1. Element html,
  2. List<CustomRenderMatcher> customRenderMatchers,
  3. List<String> tagsList,
  4. BuildContext context,
  5. HtmlParser parser,
)

lexDomTree converts a DOM document to a simplified tree of StyledElements.

Implementation

static StyledElement lexDomTree(
  dom.Element html,
  List<CustomRenderMatcher> customRenderMatchers,
  List<String> tagsList,
  BuildContext context,
  HtmlParser parser,
) {
  StyledElement tree = StyledElement(
    name: "[Tree Root]",
    children: <StyledElement>[],
    node: html,
    style: Style.fromTextStyle(Theme.of(context).textTheme.bodyMedium!),
  );

  for (var node in html.nodes) {
    tree.children.add(_recursiveLexer(
      node,
      customRenderMatchers,
      tagsList,
      context,
      parser,
    ));
  }

  return tree;
}