shouldModifyCallback = $shouldModifyCallback;
$this->modifyCallback = $modifyCallback;
// Escape U+0338 (T387130)
'@phan-var HtmlFormatter $this';
$this->textEscapes["\u{0338}"] = '̸';
}
public function element( SerializerNode $parent, SerializerNode $node, $contents ) {
if ( ( $this->shouldModifyCallback )( $node ) ) {
$node = clone $node;
$node->attrs = clone $node->attrs;
$newNode = ( $this->modifyCallback )( $node );
Assert::parameterType( [ SerializerNode::class, 'string' ], $newNode, 'return value' );
if ( is_string( $newNode ) ) {
// Replace this element with an "outerHTML" string.
return $newNode;
}
return parent::element( $parent, $newNode, $contents );
} else {
return parent::element( $parent, $node, $contents );
}
}
public function startDocument( $fragmentNamespace, $fragmentName ) {
return '';
}
}