From d9f5c2a60ee362ed85a2d7730ab775a3c2bce432 Mon Sep 17 00:00:00 2001 From: Siddharth VP Date: Sat, 12 Oct 2024 22:57:29 +0530 Subject: [PATCH] Parsoid DOM compatibility for links and copy buttons Change-Id: Ib3d30ba38753a060772029379675a5552c9631af --- includes/SyntaxHighlight.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/SyntaxHighlight.php b/includes/SyntaxHighlight.php index dacec2d2..001ca8ba 100644 --- a/includes/SyntaxHighlight.php +++ b/includes/SyntaxHighlight.php @@ -40,6 +40,7 @@ use ParserOptions; use RuntimeException; use TextContent; use WANObjectCache; +use Wikimedia\Parsoid\Core\ContentMetadataCollectorStringSets as CMCSS; use Wikimedia\Parsoid\DOM\DocumentFragment; use Wikimedia\Parsoid\Ext\ExtensionTagHandler; use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI; @@ -198,7 +199,7 @@ class SyntaxHighlight extends ExtensionTagHandler implements $parser->addTrackingCategory( $cat ); } - // Register CSS + // Register modules $parser->getOutput()->addModuleStyles( self::getModuleStyles() ); $parser->getOutput()->addModules( [ 'ext.pygments.view' ] ); return $result['html']; @@ -213,8 +214,9 @@ class SyntaxHighlight extends ExtensionTagHandler implements // FIXME: There is no API method in Parsoid to add tracking categories // So, $result['cats'] is being ignored - // Register CSS - $extApi->addModuleStyles( self::getModuleStyles() ); + // Register modules + $extApi->getMetadata()->appendOutputStrings( CMCSS::MODULE_STYLE, self::getModuleStyles() ); + $extApi->getMetadata()->appendOutputStrings( CMCSS::MODULE, [ 'ext.pygments.view' ] ); return $extApi->htmlToDom( $result['html'] ); }