blockElementRender function

CustomRender blockElementRender({
  1. Style? style,
  2. List<InlineSpan>? children,
})

Implementation

CustomRender blockElementRender({Style? style, List<InlineSpan>? children}) =>
    CustomRender.inlineSpan(inlineSpan: (context, buildChildren) {
      if (context.parser.selectable) {
        return TextSpan(
          style: context.style.generateTextStyle(),
          children: (children as List<TextSpan>?) ??
              context.tree.children
                  .expandIndexed((i, childTree) => [
                        if (childTree.style.display == Display.BLOCK &&
                            i > 0 &&
                            context.tree.children[i - 1] is ReplacedElement)
                          const TextSpan(text: "\n"),
                        context.parser.parseTree(context, childTree),
                        if (i != context.tree.children.length - 1 &&
                            childTree.style.display == Display.BLOCK &&
                            childTree.element?.localName != "html" &&
                            childTree.element?.localName != "body")
                          const TextSpan(text: "\n"),
                      ])
                  .toList(),
        );
      }
      return WidgetSpan(
          child: ContainerSpan(
        key: context.key,
        newContext: context,
        style: style ?? context.tree.style,
        shrinkWrap: context.parser.shrinkWrap,
        children: children ??
            context.tree.children
                .expandIndexed((i, childTree) => [
                      if (context.parser.shrinkWrap &&
                          childTree.style.display == Display.BLOCK &&
                          i > 0 &&
                          context.tree.children[i - 1] is ReplacedElement)
                        const TextSpan(text: "\n"),
                      context.parser.parseTree(context, childTree),
                      if (i != context.tree.children.length - 1 &&
                          childTree.style.display == Display.BLOCK &&
                          childTree.element?.localName != "html" &&
                          childTree.element?.localName != "body")
                        const TextSpan(text: "\n"),
                    ])
                .toList(),
      ));
    });