Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
ImgHandler | |
0.00% |
0 / 5 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
handle | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | declare( strict_types = 1 ); |
3 | |
4 | namespace Wikimedia\Parsoid\Html2Wt\DOMHandlers; |
5 | |
6 | use Wikimedia\Parsoid\Core\MediaStructure; |
7 | use Wikimedia\Parsoid\DOM\Element; |
8 | use Wikimedia\Parsoid\DOM\Node; |
9 | use Wikimedia\Parsoid\Html2Wt\LinkHandlerUtils; |
10 | use Wikimedia\Parsoid\Html2Wt\SerializerState; |
11 | use Wikimedia\Parsoid\Utils\DOMCompat; |
12 | use Wikimedia\Parsoid\Utils\DOMUtils; |
13 | |
14 | class ImgHandler extends DOMHandler { |
15 | |
16 | public function __construct() { |
17 | parent::__construct( false ); |
18 | } |
19 | |
20 | /** @inheritDoc */ |
21 | public function handle( |
22 | Element $node, SerializerState $state, bool $wrapperUnmodified = false |
23 | ): ?Node { |
24 | if ( DOMUtils::hasRel( $node, 'mw:externalImage' ) ) { |
25 | $state->serializer->emitWikitext( DOMCompat::getAttribute( $node, 'src' ) ?? '', $node ); |
26 | } else { |
27 | LinkHandlerUtils::figureHandler( $state, $node, new MediaStructure( $node ) ); |
28 | } |
29 | return $node->nextSibling; |
30 | } |
31 | |
32 | } |