blockElementRender function
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) => [
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(
alignment: PlaceholderAlignment.baseline,
baseline: TextBaseline.alphabetic,
child: CssBoxWidget.withInlineSpanChildren(
key: context.key,
style: style ?? context.tree.style,
shrinkWrap: context.parser.shrinkWrap,
childIsReplaced:
HtmlElements.replacedExternalElements.contains(context.tree.name),
children: children ??
context.tree.children
.expandIndexed((i, childTree) => [
context.parser.parseTree(context, childTree),
//TODO can this newline be added in a different step?
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(),
),
);
});