TheDJ has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/353065 )

Change subject: Do not extend GeSHi class with private modifications
......................................................................

Do not extend GeSHi class with private modifications

Our GeSHi class is intended for other extensions making use of GeSHi.
However other libraries or extensions can bring their own GeSHi to the
classloader. In those cases, we cannot find our private modifications
like $compatibleLexers on this class. Instead use
SyntaxHighlightGeSHiCompat for our privact modifications and keep GeSHi
closer to the original implementation.

Bug: T139594
Change-Id: I5c2ba9dfb08ec31f6b5cfd90083cbae0ae0ac3c4
---
M ResourceLoaderGeSHiVisualEditorModule.php
M SyntaxHighlight_GeSHi.class.php
M SyntaxHighlight_GeSHi.compat.php
M extension.json
4 files changed, 27 insertions(+), 18 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SyntaxHighlight_GeSHi 
refs/changes/65/353065/1

diff --git a/ResourceLoaderGeSHiVisualEditorModule.php 
b/ResourceLoaderGeSHiVisualEditorModule.php
index 64c1e41..1f2f850 100644
--- a/ResourceLoaderGeSHiVisualEditorModule.php
+++ b/ResourceLoaderGeSHiVisualEditorModule.php
@@ -35,7 +35,7 @@
                        ResourceLoader::inDebugMode()
                ) . Xml::encodeJsCall(
                        
've.dm.MWSyntaxHighlightNode.static.addGeshiToPygmentsMap', array(
-                               GeSHi::$compatibleLexers
+                               
SyntaxHighlightGeSHiCompat::getGeSHiToPygmentsMap()
                        ),
                        ResourceLoader::inDebugMode()
                ) . Xml::encodeJsCall(
diff --git a/SyntaxHighlight_GeSHi.class.php b/SyntaxHighlight_GeSHi.class.php
index e409e9c..e00a918 100644
--- a/SyntaxHighlight_GeSHi.class.php
+++ b/SyntaxHighlight_GeSHi.class.php
@@ -73,10 +73,12 @@
                        return $lexer;
                }
 
+               $geshi2pygments = 
SyntaxHighlightGeSHiCompat::getGeSHiToPygmentsMap();
+
                // Check if this is a GeSHi lexer name for which there exists
                // a compatible Pygments lexer with a different name.
-               if ( isset( GeSHi::$compatibleLexers[$lexer] ) ) {
-                       $lexer = GeSHi::$compatibleLexers[$lexer];
+               if ( isset( $geshi2pygments[$lexer] ) ) {
+                       $lexer = $geshi2pygments[$lexer];
                        if ( in_array( $lexer, $lexers ) ) {
                                return $lexer;
                        }
diff --git a/SyntaxHighlight_GeSHi.compat.php b/SyntaxHighlight_GeSHi.compat.php
index 61a808d..3f734c5 100644
--- a/SyntaxHighlight_GeSHi.compat.php
+++ b/SyntaxHighlight_GeSHi.compat.php
@@ -23,8 +23,26 @@
  * a Pygments lexer.
  */
 class GeSHi {
+       public function __construct( $html ) {
+               $this->html = $html;
+       }
+
+       public function error() {
+       }
+
+       public function set_language( $language ) {
+       }
+
+       public function parse_code() {
+               global $wgOut;
+               $wgOut->addModuleStyles( 'ext.pygments' );
+               return $this->html;
+       }
+}
+
+class SyntaxHighlightGeshiCompat {
        /** @var array A mapping of GeSHi lexer names to compatible Pygments 
lexers. */
-       public static $compatibleLexers = array(
+       private static $compatibleLexers = array(
                // Assembler
                'arm'       => 'asm',
                '6502acme'  => 'asm',
@@ -114,19 +132,7 @@
                'apt_sources' => 'debsources',
        );
 
-       public function __construct( $html ) {
-               $this->html = $html;
-       }
-
-       public function error() {
-       }
-
-       public function set_language( $language ) {
-       }
-
-       public function parse_code() {
-               global $wgOut;
-               $wgOut->addModuleStyles( 'ext.pygments' );
-               return $this->html;
+       public static function getGeSHiToPygmentsMap() {
+               return self::$compatibleLexers;
        }
 }
diff --git a/extension.json b/extension.json
index 331f6e8..453d927 100644
--- a/extension.json
+++ b/extension.json
@@ -25,6 +25,7 @@
                "SyntaxHighlight_GeSHi": "SyntaxHighlight_GeSHi.class.php",
                "GeSHi": "SyntaxHighlight_GeSHi.compat.php",
                "SyntaxHighlightAce": "SyntaxHighlight_GeSHi.ace.php",
+               "SyntaxHighlightGeSHiCompat": 
"SyntaxHighlight_GeSHi.compat.php",
                "ResourceLoaderGeSHiVisualEditorModule": 
"ResourceLoaderGeSHiVisualEditorModule.php"
        },
        "ExtensionFunctions": [

-- 
To view, visit https://gerrit.wikimedia.org/r/353065
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5c2ba9dfb08ec31f6b5cfd90083cbae0ae0ac3c4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SyntaxHighlight_GeSHi
Gerrit-Branch: master
Gerrit-Owner: TheDJ <hartman.w...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to