From b5329229c998bd67c05b740f1a92fa18debf0bd4 Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 16 Feb 2023 19:11:17 +0000 Subject: [PATCH] =?UTF-8?q?ci:=20=F0=9F=91=B7=20lint=20code=20to=20MediaWi?= =?UTF-8?q?ki=20standards?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check commit and GitHub actions for more details --- includes/TabberParsoid.php | 170 ++++++++++++++++++------------------- 1 file changed, 85 insertions(+), 85 deletions(-) diff --git a/includes/TabberParsoid.php b/includes/TabberParsoid.php index e7aa336..60edbdc 100644 --- a/includes/TabberParsoid.php +++ b/includes/TabberParsoid.php @@ -1,85 +1,85 @@ - tag in Parsoid - * - * @package TabberNeue - * @author alistair3149, Eric Fortin, Alexia E. Smith, Ciencia Al Poder - * @license GPL-3.0-or-later - * @link https://www.mediawiki.org/wiki/Extension:TabberNeue - */ - -declare( strict_types=1 ); - -namespace MediaWiki\Extension\TabberNeue; - -use Wikimedia\Parsoid\Ext\ExtensionTagHandler; -use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI; - -class TabberParsoid extends ExtensionTagHandler { - /** @inheritDoc */ - public function sourceToDom( ParsoidExtensionAPI $extApi, string $src, array $extArgs ) { - $html = self::render( $extApi, $src ); - $extApi->addModules( [ 'ext.tabberNeue' ] ); - return $extApi->htmlToDom( $html ); - } - - /** - * Renders the necessary HTML for a tag. - * - * @param PParsoidExtensionAPI $extApi - * @param string $src The input URL between the beginning and ending tags. - * - * @return string HTML - */ - public static function render( ParsoidExtensionAPI $extApi, string $src ) { - $arr = explode( "|-|", $src ); - $htmlTabs = ''; - foreach ( $arr as $tab ) { - $htmlTabs .= self::buildTab( $extApi, $tab ); - } - - $html = '
' . - '
' . $htmlTabs . "
"; - - return $html; - } - - /** - * Build individual tab. - * - * @param PParsoidExtensionAPI $extApi - * @param string $tab Tab information - * - * @return string HTML - */ - private static function buildTab( ParsoidExtensionAPI $extApi, string $tab ) { - if ( empty( trim( $tab ) ) ) { - return ''; - } - - // Use array_pad to make sure at least 2 array values are always returned - list( $tabName, $tabBody ) = array_pad( explode( '=', $tab, 2 ), 2, '' ); - - // Use language converter to get variant title and also escape html - $tabName = $parser->getTargetLanguageConverter()->convertHtml( trim( $tabName ) ); - $tabBody = $extApi->domToHTML( - $extApi->wikitextToDOM( - $tabBody, - [ - 'parseOpts' => [ - 'extTag' => 'tabber', - 'context' => 'inline', - ] - ], - true // sol - ) - ); - - $tab = '
' . $tabBody . '
'; - - return $tab; - } -} + tag in Parsoid + * + * @package TabberNeue + * @author alistair3149, Eric Fortin, Alexia E. Smith, Ciencia Al Poder + * @license GPL-3.0-or-later + * @link https://www.mediawiki.org/wiki/Extension:TabberNeue + */ + +declare( strict_types=1 ); + +namespace MediaWiki\Extension\TabberNeue; + +use Wikimedia\Parsoid\Ext\ExtensionTagHandler; +use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI; + +class TabberParsoid extends ExtensionTagHandler { + /** @inheritDoc */ + public function sourceToDom( ParsoidExtensionAPI $extApi, string $src, array $extArgs ) { + $html = self::render( $extApi, $src ); + $extApi->addModules( [ 'ext.tabberNeue' ] ); + return $extApi->htmlToDom( $html ); + } + + /** + * Renders the necessary HTML for a tag. + * + * @param PParsoidExtensionAPI $extApi + * @param string $src The input URL between the beginning and ending tags. + * + * @return string HTML + */ + public static function render( ParsoidExtensionAPI $extApi, string $src ) { + $arr = explode( "|-|", $src ); + $htmlTabs = ''; + foreach ( $arr as $tab ) { + $htmlTabs .= self::buildTab( $extApi, $tab ); + } + + $html = '
' . + '
' . $htmlTabs . "
"; + + return $html; + } + + /** + * Build individual tab. + * + * @param PParsoidExtensionAPI $extApi + * @param string $tab Tab information + * + * @return string HTML + */ + private static function buildTab( ParsoidExtensionAPI $extApi, string $tab ) { + if ( empty( trim( $tab ) ) ) { + return ''; + } + + // Use array_pad to make sure at least 2 array values are always returned + list( $tabName, $tabBody ) = array_pad( explode( '=', $tab, 2 ), 2, '' ); + + // Use language converter to get variant title and also escape html + $tabName = $parser->getTargetLanguageConverter()->convertHtml( trim( $tabName ) ); + $tabBody = $extApi->domToHTML( + $extApi->wikitextToDOM( + $tabBody, + [ + 'parseOpts' => [ + 'extTag' => 'tabber', + 'context' => 'inline', + ] + ], + true // sol + ) + ); + + $tab = '
' . $tabBody . '
'; + + return $tab; + } +}