36 public function characters( SerializerNode $parent, $text, $start, $length ) {
37 $text = parent::characters( $parent, $text, $start, $length );
39 if ( $parent->namespace !== HTMLData::NS_HTML
40 || !isset( $this->rawTextElements[$parent->name] )
42 if ( $this->textProcessor !==
null ) {
43 $text = call_user_func( $this->textProcessor, $text );
48 $text = Sanitizer::normalizeCharReferences( $text );
52 public function element( SerializerNode $parent, SerializerNode $node, $contents ) {
53 $data = $node->snData;
54 if ( $data && $data->isPWrapper ) {
55 if ( $data->nonblankNodeCount ) {
56 return "<p>$contents</p>";
63 $attrs = $node->attrs;
64 if ( isset( self::$markedEmptyElements[$name] ) && $attrs->count() === 0
65 && strspn( $contents,
"\t\n\f\r " ) === strlen( $contents )
67 return "<{$name} class=\"mw-empty-elt\">$contents</{$name}>";
71 foreach ( $attrs->getValues() as $attrName => $attrValue ) {
72 $encValue = strtr( $attrValue, $this->attributeEscapes );
73 $encValue = Sanitizer::normalizeCharReferences( $encValue );
74 $s .=
" $attrName=\"$encValue\"";
76 if ( $node->namespace === HTMLData::NS_HTML && isset( $this->voidElements[$name] ) ) {
82 if ( $node->namespace === HTMLData::NS_HTML
83 && isset( $contents[0] ) && $contents[0] ===
"\n"
84 && isset( $this->prefixLfElements[$name] )
86 $s .=
"\n$contents</$name>";
88 $s .=
"$contents</$name>";