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": { "AutoloadNamespaces": {
"MediaWiki\\Extension\\Poem\\": "includes/" "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 "manifest_version": 2
} }

View file

@ -1,40 +1,15 @@
<?php <?php
declare( strict_types = 1 ); declare( strict_types = 1 );
namespace Poem\Parsoid; namespace MediaWiki\Extension\Poem\Parsoid;
use Wikimedia\Parsoid\DOM\DocumentFragment; use Wikimedia\Parsoid\DOM\DocumentFragment;
use Wikimedia\Parsoid\Ext\ExtensionModule;
use Wikimedia\Parsoid\Ext\ExtensionTagHandler; use Wikimedia\Parsoid\Ext\ExtensionTagHandler;
use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI; use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
use Wikimedia\Parsoid\Ext\PHPUtils; use Wikimedia\Parsoid\Ext\PHPUtils;
use Wikimedia\Parsoid\Utils\DOMCompat; use Wikimedia\Parsoid\Utils\DOMCompat;
class Poem extends ExtensionTagHandler implements ExtensionModule { class Poem extends ExtensionTagHandler {
/** @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 */
}
/** @inheritDoc */ /** @inheritDoc */
public function sourceToDom( public function sourceToDom(
ParsoidExtensionAPI $extApi, string $content, array $extArgs ParsoidExtensionAPI $extApi, string $content, array $extArgs

View file

@ -1,7 +1,7 @@
<?php <?php
declare( strict_types = 1 ); declare( strict_types = 1 );
namespace Poem\Parsoid; namespace MediaWiki\Extension\Poem\Parsoid;
use Wikimedia\Parsoid\DOM\Element; use Wikimedia\Parsoid\DOM\Element;
use Wikimedia\Parsoid\DOM\Node; 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 # Force the test runner to ensure the extension is loaded
!! hooks !! hooks
poem poem