$copyBlockFormatIndent function

void $copyBlockFormatIndent(
  1. ElementNode source,
  2. ElementNode destination
)

Carries a block's own layout across a conversion.

The default $setBlocksType applies: a right-aligned, twice-indented paragraph turned into a heading is still right-aligned and twice indented, because alignment and indent describe where the block sits rather than what kind of block it is.

Implementation

void $copyBlockFormatIndent(ElementNode source, ElementNode destination) {
  final format = source.getFormat();
  final indent = source.getIndent();
  if (format != destination.getFormat()) destination.setFormat(format);
  if (indent != destination.getIndent()) destination.setIndent(indent);
}