40 public function characters( SerializerNode $parent, $text, $start, $length ) {
41 $text = parent::characters( $parent, $text, $start, $length );
43 if ( $parent->namespace !== HTMLData::NS_HTML
44 || !isset( $this->rawTextElements[$parent->name] )
46 if ( $this->textProcessor !==
null ) {
47 $text = call_user_func( $this->textProcessor, $text );
51 $text = Sanitizer::normalizeCharReferences( $text );
57 public function element( SerializerNode $parent, SerializerNode $node, $contents ) {
58 $data = $node->snData;
59 if ( $data && $data->isPWrapper ) {
60 if ( $data->nonblankNodeCount ) {
61 return "<p>$contents</p>";
68 $attrs = $node->attrs;
69 if ( isset( self::$markedEmptyElements[$name] ) && $attrs->count() === 0
70 && strspn( $contents,
"\t\n\f\r " ) === strlen( $contents )
72 return "<{$name} class=\"mw-empty-elt\">$contents</{$name}>";
76 foreach ( $attrs->getValues() as $attrName => $attrValue ) {
77 $encValue = strtr( $attrValue, $this->attributeEscapes );
78 $encValue = Sanitizer::normalizeCharReferences( $encValue );
79 $s .=
" $attrName=\"$encValue\"";
81 if ( $node->namespace === HTMLData::NS_HTML && isset( $this->voidElements[$name] ) ) {
87 if ( $node->namespace === HTMLData::NS_HTML
88 && isset( $contents[0] ) && $contents[0] ===
"\n"
89 && isset( $this->prefixLfElements[$name] )
91 $s .=
"\n$contents</$name>";
93 $s .=
"$contents</$name>";