Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / tidy / RemexCompatBuilder.php
blobfea5a7a09f77e687be7b52925f69d4ed1ab40969
1 <?php
3 namespace MediaWiki\Tidy;
5 use Wikimedia\RemexHtml\TreeBuilder\Marker;
6 use Wikimedia\RemexHtml\TreeBuilder\TreeBuilder;
8 /**
9 * @internal
11 class RemexCompatBuilder extends TreeBuilder {
12 public function reconstructAFE( $sourceStart ) {
13 // These checks are redundant with the parent, but here for performance
14 $entry = $this->afe->getTail();
15 if ( !$entry || $entry instanceof Marker || $entry->stackIndex !== null ) {
16 return;
19 // Don't reconstruct AFE in file figures to respect the spec,
20 // https://www.mediawiki.org/wiki/Specs/HTML#Media
21 $len = $this->stack->length();
22 while ( $len > 0 ) {
23 $i = $this->stack->item( $len - 1 );
24 if ( $i->htmlName === 'figcaption' ) {
25 break;
27 if ( $i->htmlName === 'figure' ) {
28 foreach ( $i->attrs->getValues() as $k => $v ) {
29 if ( $k === 'typeof' && preg_match( '/\bmw:File\b/', $v ) ) {
30 return;
33 break;
35 $len--;
37 parent::reconstructAFE( $sourceStart );