diff --git a/.github/workflows/mediawiki-tests.yml b/.github/workflows/mediawiki-tests.yml index ecf6a7ab..c909bfbf 100644 --- a/.github/workflows/mediawiki-tests.yml +++ b/.github/workflows/mediawiki-tests.yml @@ -13,46 +13,18 @@ jobs: strategy: matrix: include: - # Latest MediaWiki LTS - PHP 8.2 (phan) - - mw: 'REL1_43' - php: 8.2 - php-docker: 82 - experimental: false - stage: phan - - # Latest MediaWiki LTS - PHP 8.2 (phpunit) - - mw: 'REL1_43' - php: 8.2 - php-docker: 82 - experimental: false - stage: phpunit - - # Legacy MediaWiki stable - PHP 8.2 (phan) - - mw: 'REL1_44' - php: 8.2 - php-docker: 82 - experimental: false - stage: phan - - # Legacy MediaWiki stable - PHP 8.2 (phpunit) - - mw: 'REL1_44' - php: 8.2 - php-docker: 82 - experimental: false - stage: phpunit - # Latest MediaWiki stable - PHP 8.2 (phan) - mw: 'REL1_45' php: 8.2 php-docker: 82 - experimental: true + experimental: false stage: phan # Latest MediaWiki stable - PHP 8.4 (phan) - mw: 'REL1_45' php: 8.4 php-docker: 84 - experimental: true + experimental: false stage: phan # Latest MediaWiki stable - PHP 8.2 (phpunit) diff --git a/README.md b/README.md index 1323a7dc..d8e1ccc4 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,12 @@ You can use several variables to modify extension's behaviour: - `$wgPortableInfoboxResponsiblyOpenCollapsed` (bool) - open collapsed groups when the screen is narrow. (default: true) - `$wgPortableInfoboxUseFileDescriptionPage` (bool) - control whether or not embedded images in the infobox will link to their file description page instead of directly to the file. (default: false) +### Parsoid +PortableInfobox has support for displaying infoboxes when rendering an article using Parsoid. This has been tested against MediaWiki 1.45 and is not guaranteed to work in earlier versions. + +There are still some issues, and the implementation is not bug free, however it should display most infoboxes - infoboxes will also display in the VisualEditor. + +When using PortableInfoboxes and Parsoid, you **must** set `$wgPortableInfoboxUseHeadings = false` otherwise Parsoid will wrap the headings in the infobox in section tags which will break formatting and styling. ## Usage See: https://community.fandom.com/wiki/Help:Infoboxes diff --git a/extension.json b/extension.json index 349d9bbd..41520fa8 100644 --- a/extension.json +++ b/extension.json @@ -7,15 +7,19 @@ ], "url": "https://github.com/Universal-Omega/PortableInfobox", "descriptionmsg": "portable-infobox-desc", - "version": "0.8", + "version": "1.0", "type": "parserhook", "license-name": "GPL-3.0-or-later", "requires": { - "MediaWiki": ">= 1.43.0" + "MediaWiki": ">= 1.45.0" }, "config": { "AllInfoboxesExcludedSubpages": { - "value": [ "doc", "draft", "test" ] + "value": [ + "doc", + "draft", + "test" + ] }, "PortableInfoboxCacheRenderers": { "value": false @@ -125,5 +129,6 @@ "APIListModules": { "allinfoboxes": "PortableInfobox\\Controllers\\ApiQueryAllInfoboxes" }, + "ParsoidModules": [ "PortableInfobox\\Parsoid\\InfoboxTag" ], "manifest_version": 2 } diff --git a/includes/Parsoid/InfoboxTag.php b/includes/Parsoid/InfoboxTag.php new file mode 100644 index 00000000..d59e1170 --- /dev/null +++ b/includes/Parsoid/InfoboxTag.php @@ -0,0 +1,49 @@ + 'PortableInfobox', + 'tags' => [ + [ + 'name' => 'infobox', + 'handler' => self::class, + ], + ], + 'domProcessors' => [ + 'PortableInfobox\\Parsoid\\PortableInfoboxDOMProcessor', + ], + ]; + } + + /** + * @inheritDoc + */ + public function sourceToDom( ParsoidExtensionAPI $api, string $src, array $args ) { + $domFragments = $api->extTagToDOM( $args, $src, [ + 'wrapperTag' => 'aside', + 'parseOpts' => [ + 'extTag' => 'infobox', + 'context' => 'inline', + ], + ] ); + + $api->getMetadata()->appendOutputStrings( CMCSS::MODULE_STYLE, [ 'ext.PortableInfobox.styles' ] ); + $api->getMetadata()->appendOutputStrings( CMCSS::MODULE, [ 'ext.PortableInfobox.scripts' ] ); + + // return this back. At this point, we have constructed the outer tag (