X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Ftidy%2FRemexCompatMunger.php;h=a37f4f76f06b66edc9497d2614c5f53b737d8dfe;hb=3d3198f4b0ab4d070e65e3c2c8706b73f2dbddbb;hp=78a11045ed1d1e8dadf79d5f23103a0ae0907fac;hpb=15f6eff90c305d405fe4331c8a8dc8caa842e5b3;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/tidy/RemexCompatMunger.php b/includes/tidy/RemexCompatMunger.php index 78a11045ed..a37f4f76f0 100644 --- a/includes/tidy/RemexCompatMunger.php +++ b/includes/tidy/RemexCompatMunger.php @@ -72,6 +72,21 @@ class RemexCompatMunger implements TreeHandler { "mark" => true, ]; + /** + * For the purposes of this class, "metadata" elements are those that + * should neither trigger p-wrapping nor stop an outer p-wrapping, + * typically those that are themselves invisible in a browser's rendering. + * This isn't a complete list, it's just the tags that we're likely to + * encounter in practice. + * @var array + */ + private static $metadataElements = [ + 'style' => true, + 'script' => true, + 'link' => true, + 'meta' => true, + ]; + private static $formattingElements = [ 'a' => true, 'b' => true, @@ -261,14 +276,17 @@ class RemexCompatMunger implements TreeHandler { $under = $preposition === TreeBuilder::UNDER; $elementToEnd = null; - if ( $under && $parentData->isPWrapper && !$inline ) { + if ( isset( self::$metadataElements[$elementName] ) ) { + // The element is a metadata element, that we allow to appear in + // both inline and block contexts. + $this->trace( 'insert metadata' ); + } elseif ( $under && $parentData->isPWrapper && !$inline ) { // [B/b] The element is non-inline and the parent is a p-wrapper, // close the parent and insert into its parent instead $this->trace( 'insert B/b' ); $newParent = $this->serializer->getParentNode( $parent ); $parent = $newParent; $parentData = $parent->snData; - $pElement = $parentData->childPElement; $parentData->childPElement = null; $newRef = $refElement->userData; } elseif ( $under && $parentData->isSplittable @@ -464,9 +482,8 @@ class RemexCompatMunger implements TreeHandler { } public function comment( $preposition, $refElement, $text, $sourceStart, $sourceLength ) { - list( $parent, $refNode ) = $this->getParentForInsert( $preposition, $refElement ); - $this->serializer->comment( $preposition, $refNode, $text, - $sourceStart, $sourceLength ); + list( , $refNode ) = $this->getParentForInsert( $preposition, $refElement ); + $this->serializer->comment( $preposition, $refNode, $text, $sourceStart, $sourceLength ); } public function error( $text, $pos ) {