Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
ParsoidWikitextParser | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
parse | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Kartographer; |
4 | |
5 | use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI; |
6 | |
7 | /** |
8 | * @license MIT |
9 | */ |
10 | class ParsoidWikitextParser extends WikitextParser { |
11 | |
12 | private ParsoidExtensionAPI $extApi; |
13 | |
14 | public function __construct( ParsoidExtensionAPI $extApi ) { |
15 | $this->extApi = $extApi; |
16 | } |
17 | |
18 | /** @inheritDoc */ |
19 | protected function parse( string $wikiText ): string { |
20 | $dom = $this->extApi->wikitextToDOM( $wikiText, [ |
21 | 'parseOpts' => [ |
22 | 'extTag' => $this->extApi->extTag->getName(), |
23 | 'context' => 'inline', |
24 | ], |
25 | // the wikitext is embedded into a JSON attribute, processing in a new frame seems to be the right move |
26 | // to avoid DSR failures |
27 | 'processInNewFrame' => true, |
28 | 'clearDSROffsets' => true, |
29 | ], false ); |
30 | return $this->extApi->domToHtml( $dom, false, true ); |
31 | } |
32 | } |