From b8a5dd08ee01686118439e3b44b991270d39b46b Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Thu, 2 Sep 2021 19:35:45 -0700 Subject: [PATCH] Expose Pygments version on Special:Version Change-Id: Ia4eccc4f16873b16e106c8196d7582ca5b27b365 --- extension.json | 3 ++- includes/SyntaxHighlight.php | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/extension.json b/extension.json index 44eb6d24..8ada4798 100644 --- a/extension.json +++ b/extension.json @@ -101,7 +101,8 @@ ], "ApiFormatHighlight": [ "SyntaxHighlight::onApiFormatHighlight" - ] + ], + "SoftwareInfo": "SyntaxHighlight::onSoftwareInfo" }, "attributes": { "SyntaxHighlight": { diff --git a/includes/SyntaxHighlight.php b/includes/SyntaxHighlight.php index 6ad539a1..940bb2eb 100644 --- a/includes/SyntaxHighlight.php +++ b/includes/SyntaxHighlight.php @@ -558,4 +558,18 @@ class SyntaxHighlight { // Inform MediaWiki that we have parsed this page and it shouldn't mess with it. return false; } + + /** + * Hook to add Pygments version to Special:Version + * + * @see https://www.mediawiki.org/wiki/Manual:Hooks/SoftwareInfo + * @param array &$software + */ + public static function onSoftwareInfo( array &$software ) { + try { + $software['[https://pygments.org/ Pygments]'] = Pygmentize::getVersion(); + } catch ( PygmentsException $e ) { + // pass + } + } }