Hook up Parsoid implementation of Poem

Bug: T358054
Change-Id: Iac1378b1761842e5c2b82129abb191fbf16d829c
This commit is contained in:
Arlo Breault 2024-02-26 18:45:38 -05:00
parent e07bcb81c8
commit 3cc0dd4e6e
5 changed files with 24 additions and 29 deletions

View file

@ -28,5 +28,20 @@
"AutoloadNamespaces": {
"MediaWiki\\Extension\\Poem\\": "includes/"
},
"ParsoidModules": [ {
"name": "Poem",
"domProcessors": [
"MediaWiki\\Extension\\Poem\\Parsoid\\PoemProcessor"
],
"tags": [
{
"name": "poem",
"handler": "MediaWiki\\Extension\\Poem\\Parsoid\\Poem",
"options": {
"outputHasCoreMwDomSpecMarkup": true
}
}
]
} ],
"manifest_version": 2
}

View file

@ -1,40 +1,15 @@
<?php
declare( strict_types = 1 );
namespace Poem\Parsoid;
namespace MediaWiki\Extension\Poem\Parsoid;
use Wikimedia\Parsoid\DOM\DocumentFragment;
use Wikimedia\Parsoid\Ext\ExtensionModule;
use Wikimedia\Parsoid\Ext\ExtensionTagHandler;
use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
use Wikimedia\Parsoid\Ext\PHPUtils;
use Wikimedia\Parsoid\Utils\DOMCompat;
class Poem extends ExtensionTagHandler implements ExtensionModule {
/** @inheritDoc */
public function getConfig(): array {
return [
'name' => 'Poem',
'domProcessors' => [
PoemProcessor::class,
],
'tags' => [
[
'name' => 'poem',
'handler' => self::class,
'options' => [
'outputHasCoreMwDomSpecMarkup' => true
],
]
]
];
}
public function __construct( ?ParsoidExtensionAPI $extApi = null ) {
/* The dom post processor doesn't need to use $extApi, so ignore it */
}
class Poem extends ExtensionTagHandler {
/** @inheritDoc */
public function sourceToDom(
ParsoidExtensionAPI $extApi, string $content, array $extArgs

View file

@ -1,7 +1,7 @@
<?php
declare( strict_types = 1 );
namespace Poem\Parsoid;
namespace MediaWiki\Extension\Poem\Parsoid;
use Wikimedia\Parsoid\DOM\Element;
use Wikimedia\Parsoid\DOM\Node;

View file

@ -0,0 +1 @@
{}

View file

@ -1,4 +1,8 @@
!! Version 2
!! options
version=2
parsoid-compatible=wt2html,wt2wt,html2wt,html2html,selser
!! end
# Force the test runner to ensure the extension is loaded
!! hooks
poem