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 );
52 $text = Sanitizer::normalizeCharReferences( $text );
56 public function element( SerializerNode $parent, SerializerNode $node, $contents ) {
57 $data = $node->snData;
58 if ( $data && $data->isPWrapper ) {
59 if ( $data->nonblankNodeCount ) {
60 return "<p>$contents</p>";
67 $attrs = $node->attrs;
68 if ( isset( self::$markedEmptyElements[$name] ) && $attrs->count() === 0
69 && strspn( $contents,
"\t\n\f\r " ) === strlen( $contents )
71 return "<{$name} class=\"mw-empty-elt\">$contents</{$name}>";
75 foreach ( $attrs->getValues() as $attrName => $attrValue ) {
76 $encValue = strtr( $attrValue, $this->attributeEscapes );
77 $encValue = Sanitizer::normalizeCharReferences( $encValue );
78 $s .=
" $attrName=\"$encValue\"";
80 if ( $node->namespace === HTMLData::NS_HTML && isset( $this->voidElements[$name] ) ) {
86 if ( $node->namespace === HTMLData::NS_HTML
87 && isset( $contents[0] ) && $contents[0] ===
"\n"
88 && isset( $this->prefixLfElements[$name] )
90 $s .=
"\n$contents</$name>";
92 $s .=
"$contents</$name>";