23 public function __construct( $options, callable $shouldModifyCallback, callable $modifyCallback ) {
24 parent::__construct( $options );
25 $this->shouldModifyCallback = $shouldModifyCallback;
26 $this->modifyCallback = $modifyCallback;
28 '@phan-var HtmlFormatter $this';
29 $this->textEscapes[
"\u{0338}"] =
'̸';
32 public function element( SerializerNode $parent, SerializerNode $node, $contents ) {
33 if ( ( $this->shouldModifyCallback )( $node ) ) {
35 $node->attrs = clone $node->attrs;
36 $newNode = ( $this->modifyCallback )( $node );
37 Assert::parameterType( [ SerializerNode::class,
'string' ], $newNode,
'return value' );
38 if ( is_string( $newNode ) ) {
42 return parent::element( $parent, $newNode, $contents );
44 return parent::element( $parent, $node, $contents );