5 use RemexHtml\HTMLData;
6 use RemexHtml\Serializer\HtmlFormatter;
7 use RemexHtml\Serializer\SerializerNode;
8 use RemexHtml\Tokenizer\PlainAttributes;
22 $this->attributeEscapes[
"\xc2\xa0"] =
' ';
23 unset( $this->attributeEscapes[
"&"] );
24 $this->textEscapes[
"\xc2\xa0"] =
' ';
25 unset( $this->textEscapes[
"&"] );
32 public function element( SerializerNode $parent, SerializerNode $node, $contents ) {
33 $data = $node->snData;
34 if ( $data && $data->isPWrapper ) {
35 if ( $data->nonblankNodeCount ) {
36 return "<p>$contents</p>";
43 $attrs = $node->attrs;
44 if ( isset( self::$markedEmptyElements[
$name] ) && $attrs->count() === 0 ) {
45 if ( strspn( $contents,
"\t\n\f\r " ) === strlen( $contents ) ) {
46 return "<{$name} class=\"mw-empty-elt\">$contents</{$name}>";
51 foreach ( $attrs->getValues()
as $attrName => $attrValue ) {
52 $encValue = strtr( $attrValue, $this->attributeEscapes );
53 $s .=
" $attrName=\"$encValue\"";
55 if ( $node->namespace === HTMLData::NS_HTML && isset( $this->voidElements[
$name] ) ) {
61 if ( $node->namespace === HTMLData::NS_HTML
62 && isset( $contents[0] ) && $contents[0] ===
"\n"
63 && isset( $this->prefixLfElements[
$name] )
65 $s .=
"\n$contents</$name>";
67 $s .=
"$contents</$name>";