Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 30 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
LST | |
0.00% |
0 / 30 |
|
0.00% |
0 / 2 |
30 | |
0.00% |
0 / 1 |
getConfig | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
2 | |||
domToWikitext | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
20 |
1 | <?php |
2 | declare( strict_types = 1 ); |
3 | |
4 | namespace Wikimedia\Parsoid\Ext\LST; |
5 | |
6 | use Wikimedia\Parsoid\DOM\Element; |
7 | use Wikimedia\Parsoid\Ext\DOMDataUtils; |
8 | use Wikimedia\Parsoid\Ext\DOMUtils; |
9 | use Wikimedia\Parsoid\Ext\ExtensionModule; |
10 | use Wikimedia\Parsoid\Ext\ExtensionTagHandler; |
11 | use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI; |
12 | use Wikimedia\Parsoid\Utils\DOMCompat; |
13 | |
14 | class LST extends ExtensionTagHandler implements ExtensionModule { |
15 | |
16 | /** @inheritDoc */ |
17 | public function getConfig(): array { |
18 | return [ |
19 | 'name' => 'LST', |
20 | 'tags' => [ |
21 | [ |
22 | 'name' => 'labeledsectiontransclusion', |
23 | 'handler' => self::class, |
24 | ], |
25 | [ |
26 | 'name' => 'labeledsectiontransclusion/begin', |
27 | 'handler' => self::class, |
28 | ], |
29 | [ |
30 | 'name' => 'labeledsectiontransclusion/end', |
31 | 'handler' => self::class, |
32 | ] |
33 | ] |
34 | ]; |
35 | } |
36 | |
37 | /** @inheritDoc */ |
38 | public function domToWikitext( |
39 | ParsoidExtensionAPI $extApi, Element $node, bool $wrapperUnmodified |
40 | ) { |
41 | // TODO: We're keeping this serial handler around to remain backwards |
42 | // compatible with stored content version 1.3.0 and below. Remove it |
43 | // when those versions are no longer supported. |
44 | |
45 | $dp = DOMDataUtils::getDataParsoid( $node ); |
46 | $src = null; |
47 | $content = DOMCompat::getAttribute( $node, 'content' ) ?? ''; |
48 | if ( isset( $dp->src ) ) { |
49 | $src = $dp->src; |
50 | } elseif ( DOMUtils::matchTypeOf( $node, '/begin/' ) ) { |
51 | $src = '<section begin="' . $content . '" />'; |
52 | } elseif ( DOMUtils::matchTypeOf( $node, '/end/' ) ) { |
53 | $src = '<section end="' . $content . '" />'; |
54 | } else { |
55 | $extApi->log( 'error', 'LST <section> without content in: ' . |
56 | DOMCompat::getOuterHTML( $node ) ); |
57 | $src = '<section />'; |
58 | } |
59 | return $src; |
60 | } |
61 | |
62 | } |