Skip to content

Commit 8278e66

Browse files
committed
refactor: update Parsoid implementation
Note that it is not enabled, still a WIP
1 parent a4e5905 commit 8278e66

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

includes/TabberParsoid.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,28 @@
1414

1515
namespace MediaWiki\Extension\TabberNeue;
1616

17+
use Wikimedia\Parsoid\Ext\ExtensionModule;
1718
use Wikimedia\Parsoid\Ext\ExtensionTagHandler;
1819
use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
1920

20-
class TabberParsoid extends ExtensionTagHandler {
21+
class TabberParsoid extends ExtensionTagHandler implements ExtensionModule {
22+
/** @inheritDoc */
23+
public function getConfig(): array {
24+
return [
25+
'name' => 'TabberNeue',
26+
'tags' => [
27+
[
28+
'name' => 'tabber',
29+
'handler' => self::class
30+
]
31+
]
32+
];
33+
}
34+
2135
/** @inheritDoc */
2236
public function sourceToDom( ParsoidExtensionAPI $extApi, string $src, array $extArgs ) {
2337
$html = self::render( $extApi, $src );
24-
$extApi->addModules( [ 'ext.tabberNeue' ] );
38+
$extApi->addModules( [ 'ext.tabberNeue.codex' ] );
2539
return $extApi->htmlToDom( $html );
2640
}
2741

@@ -41,6 +55,7 @@ public static function render( ParsoidExtensionAPI $extApi, string $src ) {
4155
}
4256

4357
$html = '<div class="tabber">' .
58+
'<header class="tabber__header"></header>' .
4459
'<section class="tabber__section">' . $htmlTabs . "</section></div>";
4560

4661
return $html;
@@ -62,8 +77,12 @@ private static function buildTab( ParsoidExtensionAPI $extApi, string $tab ) {
6277
// Use array_pad to make sure at least 2 array values are always returned
6378
list( $tabName, $tabBody ) = array_pad( explode( '=', $tab, 2 ), 2, '' );
6479

65-
// Use language converter to get variant title and also escape html
66-
$tabName = $parser->getTargetLanguageConverter()->convertHtml( trim( $tabName ) );
80+
/*
81+
* Use language converter to get variant title and also escape html
82+
* FIXME: No replacement method yet
83+
* See T85581, T272943
84+
*/
85+
// $tabName = $parser->getTargetLanguageConverter()->convertHtml( trim( $tabName ) );
6786
$tabBody = $extApi->domToHTML(
6887
$extApi->wikitextToDOM(
6988
$tabBody,

0 commit comments

Comments
 (0)