Extension talk:SyntaxHighlight

About this board

Previous discussion was archived at Extension talk:SyntaxHighlight/Archive 2017 on 2017-03-29.

Some lexers put pages using <syntaxhighlight> in the tracking category

Snowyamur9889 (talkcontribs)

Pygments lexers like "lua", "html", and "css" put pages using <syntaxhighlight> into "Category:Pages with syntax highlighting errors", despite these lexers being correct. Maybe there are other lexers causing this problem - I don't know. But the three I mentioned above are the ones I commonly use for template/module documentation.

I don't know why this happens. The wiki I contribute to runs on MediaWiki 1.39 with Extension:SyntaxHighlight version 2.0. The Pygments documentation states that these Short names: for the lexers I mentioned above are correct, so why are the pages that use them with <syntaxhighlight> placed in the tracking category?

Does anyone know?

Tacsipacsi (talkcontribs)

Does the code get highlighted? (It’s always good to share a link so that I can answer such simple questions on my own.) The error category gets added whenever the highlighting is unsuccessful – this includes not only incorrect lexer names, but also when the code is too big or calling Pygments fails for any reason.

Snowyamur9889 (talkcontribs)

The code gets highlighted, so I don't know why pages using <syntaxhighlight> end up in the tracking category. There are pages in the tracking category for this wiki that use syntax highlighting correctly but still end up categorized.

Tacsipacsi (talkcontribs)

Could you please provide a link? It’s very hard to debug without being able to see what exactly is happening.

Reply to "Some lexers put pages using <syntaxhighlight> in the tracking category"

Windows (XAMPP), fwrite(): Write of 17 bytes failed with errno=22 Invalid argument in [...]\\includes\\shell\\Command.php

Escalatr (talkcontribs)

According to the extension´s documentation, it should run on Windows, can anyone confirm that?

Apache Error.log message: fwrite(): Write of 17 bytes failed with errno=22 Invalid argument in C:\\xampp\\htdocs\\wiki\\includes\\shell\\Command.php

(Unfortunately, I get no other messages even with more debug options on)

  • MediaWiki: 1.35.3
  • Windows 10 64bit
  • Python 3.11 and Pygments package installed

There are several hack suggestions in the talk pages: Topic:Vibz8ak3wnpu9mv8, Topic:V4n3pjg78pvmh12n (no temp out files created), Topic:Ugtwpe4lyuly6q98. None of them helped me so far.

I also found this entry: https://phabricator.wikimedia.org/T199989

After editing Command.php with the proposed patch (https://gerrit.wikimedia.org/r/c/mediawiki/core/+/762736/4/includes/shell/Command.php), the extension works. However, I would prefer a proper solution without hacking the MediaWiki core.

Tystnaden (talkcontribs)

I suggest that you upgrade to MediaWiki 1.39.X, which is the current LTS release. Note that MediaWiki 1.35 is going EOL in September 2023. See https://phabricator.wikimedia.org/T199989 for the details about this issue.

Escalatr (talkcontribs)

An update to MW 1.39 ist definitely planned, my understanding: the issue is solved there with Shellbox.

However, the installation does not look trivial to me... Does it run on Windows?

In my case, the whole idea of the Windows version is to offer a ready-to-run package for colleagues without direct access to our original Wiki (which runs on Linux).

Reply to "Windows (XAMPP), fwrite(): Write of 17 bytes failed with errno=22 Invalid argument in [...]\\includes\\shell\\Command.php"

Dirty Hack to get it work on Windows

5 (talkcontribs)

Since passing parameters and results to the pygmentizer through stdin/stdout does not work on Windows,

i tried to use files for input and output. Pleas adjust the temporary directory to your environment.

Works for me on MediaWiki 1.33.


Ralf Naujokat

function ( $oldValue, &$ttl ) use ( $code, $lexer, $options, &$error ) {
	$optionPairs = [];
	foreach ( $options as $k => $v ) {
		$optionPairs[] = "{$k}={$v}";
	$tmp = tempnam( 'D:\\MediaWiki\\tmp', 'SH' );
	$tmp_out = $tmp . ".out";
	$tmp_in  = $tmp . ".in";
	file_put_contents( $tmp_in, $code );
	$result = Shell::command(
		self::getPygmentizePath() .
		' -l ' . $lexer .
		' -f ' . 'html' .
		' -O ' . implode( ',', $optionPairs ) . 
		' -o ' . $tmp_out . 
		' '    . $tmp_in 
		// ->input( $code )
		->restrict( Shell::RESTRICT_DEFAULT | Shell::NO_NETWORK )

	if ( $result->getExitCode() != 0 ) {
		$ttl = WANObjectCache::TTL_UNCACHEABLE;
		$error = $result->getStderr();
		return null;

	$out = file_get_contents( $tmp_out );
	unlink( $tmp );
	unlink( $tmp_in );
	unlink( $tmp_out );
	return $out;
} (talkcontribs)

Oops, forgot to mention:

Modify the file 'includes\SyntaxHighlight.php', starting at line 305 (talkcontribs)

Thank you so much for sharing this - I was ripping my hair out! (talkcontribs)

Also thank you, but have you get syntax highlighter working when attribute highlight is used (highlight="1,5,6" for example)?

Escalatr (talkcontribs)

I´ve tried with MediaWiki 1.35.3, but the tmp.out files are not created for the results, thus not working so far.

Reply to "Dirty Hack to get it work on Windows"

PHP error with message "requires shell ability"

Атомный трамвай (talkcontribs)

Enabling this extension lead to error: 1319 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught ExtensionDependencyError: SyntaxHighlight requires "shell" ability: Unable to run external programs, proc_open() is disabled." All pages is blank. MW 1.39.1.

Any ideas what to do?

Keyacom (talkcontribs)

If proc_open() is disabled, you must enable it in php.ini (you can't enable it from anywhere else). Contact your hosting provider if you can't get root access.

Атомный трамвай (talkcontribs)

OK, thanks, done. But it's strange that message don't just tell to enable proc_open and confuse me with additional info. Finally, it works (while CodeEditor still don't :( ).

Reply to "PHP error with message "requires shell ability""
Polymath uk (talkcontribs)

I have a brand new, uncustomised install:

MediaWiki 1.39.1
PHP 7.4.33 (apache2handler)
MariaDB 10.5.18-MariaDB-0+deb11u1
ICU 67.1
Lua 5.1.5
Pygments 2.11.2

I cannot get line numbers to work with sytaxhighligh (as invoked through wfLoadExtension( 'SyntaxHighlight_GeSHi' ); in LocalSettings.php.

It otherwise behaves perfectly. Any ideas?

Peculiar Investor (talkcontribs)

Any chance you are running the wiki on a shared hosting plan? If so, check that python3 is installed and can be called by pygmentize.

Polymath uk (talkcontribs)

There's no chance of that because I'm hosting it myself.

However..... I am experimenting with containers (LXC) and I have read somewhere that it is possible that something in /proc cannot be properly accessed by systems in containers, and this affects the rendering. I think its likely this is the problem for me. Oddly, line numbers appear in the visual editor code window, they just disappear when the edit is committed.

Jdforrester (WMF) (talkcontribs)

That's because the line numbers inside the editor are provided by different software (the editor, which runs in client-side JS, instead of the SyntaxHighlight extension's server-side call out to Pygments).

Want (talkcontribs)

Could you indicate here how your syntax of syntaxhighlight element looks like, please? Thank you.

Polymath uk (talkcontribs)

This is a typical example:

<syntaxhighlight lang="php" line>

$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'doc', 'xls', 'mpp', 'pdf', 'ppt', 'tiff', 'bmp', 'docx', 'xlsx', 'pptx', 'ps', 'odt', 'ods', 'odp', 'odg');


Want (talkcontribs)
Reply to "No line numbers"

Showing line numbers to those reading Module: pages

Summary by Jdforrester (WMF)

Feature is new in the forthcoming 1.36 release.

Peculiar Investor (talkcontribs)

What setting or CSS is required to make line numbers appear on Module pages such as Module:Bananas or Wikipedia's Module:Example?

Our wiki is running 1.35.1, with up-to-date versions of Extension:Scribunto and Extension:SyntaxHighlight.

Our wiki has imported Wikipedia's Module:Example and the code is syntax highlighted as expected but there are no line numbers. Our MediaWiki:Common.css is copied from Wikipedia. We are trying to figure out what setting or CSS is required so that line numbering appears. Thanks in advance.

Jdforrester (WMF) (talkcontribs)

It's new code from last month. It will be released as part of the 1.36 branch process later this year, sorry.

Peculiar Investor (talkcontribs)

@Jdforrester (WMF) Thanks. Now I can stop searching. The good news is I've learned quite a bit about the internals.

Peculiar Investor (talkcontribs)

Re-opening rather than starting new topic.

We have now updated the wiki to MediaWiki 1.39.1 and we still have the same issue, or actually a bigger one as none of the SyntaxHighlight functionality displays.

The wiki is running on shared hosting at a major hosting provided. python3 is installed as an "add-on" functionality.

I have tried the steps listed in the Troubleshooting section without success. I finally set $wgDebugToolbar = true; which reveals the pygmentize cannot find python3.

That's because the hosting provider only has python version 2.7.5. The python3 "add-on" installation is not on the Apache or PHP path.

Is there any additional configuration steps similar to $wgPygmentizePath = that could be used to provide the python3 path?

Reply to "Showing line numbers to those reading Module: pages"

How to write </syntaxhighlight> inside <syntaxhighlight></syntaxhighlight>?

Summary by Tacsipacsi

Using {{#tag:}} and some extra hack.

2A01:E0A:AE5:F900:225:22FF:FE67:EEA2 (talkcontribs)

Is it possible to write </syntaxhighlight> inside a syntaxhighlight without being interpreted as the end of it ? I mean, it's possible, since the presentation page did it… But reading the source code didn't give me a clue about how to do it!

Tacsipacsi (talkcontribs)

You have to use {{#tag:syntaxhighlight|...}} for the actual highlighting, putting the code to be highlighted in place of the .... However, if you’d just put <syntaxhighlight></syntaxhighlight> there, MediaWiki tried to interpret that as well, resulting in something like '"`UNIQ--syntaxhighlight-00000001-QINU`"' being the content. You have to stop MediaWiki somehow from interpreting the content, which can be done in several ways. This page replaces the leading < sign with a call to the template {{^(}}, but if you don’t want to create a such template on your wiki, putting a <nowiki /> somewhere in the middle of the opening tag (e.g. <syntax<nowiki />highlight>) should also work.

2A01:E0A:AE5:F900:225:22FF:FE67:EEA2 (talkcontribs)

It looks like the "nowiki" tag can't be used simultaneously with the #tag thing on my MediaWiki without the #tag thing bugging. But I'll do with the template thing.

Thank you

Some lexers work, others not

Olarp (talkcontribs)

Running MediaWiki 1.38.4 on

  • Windows Server 2019
  • IIS 10
  • PHP 8.1.13
  • Python 3.11
  • Pygmentize 2.13.0

For unknown reasons some lexers work while other don't and instead generate the "Pages with syntax highlighting errors"-category. The page below, as an example, generates the powershell and bash code correctly, but not the yaml.

If I swap the yaml for bash without changing the block of code below, it does not generate an "Pages with syntax highlighting" category of it, and of course it doesn't highlight it correctly either as it is trying to bash highlight a yaml snippet.

<syntaxhighlight lang="powershell">
# This is a PowerShell script
Write-Host "Hello world"

<syntaxhighlight lang="bash">
# This is a shell script in bash
ls -l /var/lib

<syntaxhighlight lang="yaml">
# This is a yaml block
- martin:
    job: Developer

I did not try all lexers supported by pygmentize. But it seems some work, some not. powershell and bash works every time, yaml and text fails everytime. It doesn't matter what order the blocks are on the page, they can be alone and it still fails. I checked the file SyntaxHighlight.lexers.php and all the lexers that pygmentize support are there, marked as true.

This is what debug output looks for the above page, relevant section. Note it only runs pygmentize four times. First time with version check, second with lexers check, third and fourth is the syntax highlight blocks that work.

[DBQuery] MediaWiki\Storage\SqlBlobStore::fetchBlobs [0s] SELECT old_id,old_text,old_flags FROM `text` WHERE old_id = 1822
[objectcache] fetchOrRegenerate(global:SqlBlobStore-blob:hkr_mediawiki:tt%3A1822): miss, new value computed
[exec] Creating base path C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-0b8cf480f6bf3322
[exec] Executing: cmd /s /c ""c:\Progra~1\Python311\Scripts\pygmentize.exe" "-V"" 2>&1
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-0b8cf480f6bf3322/sb-stderr"
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-0b8cf480f6bf3322/sb-stdout"
[exec] Removed directory "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-0b8cf480f6bf3322"
[exec] Creating base path C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-86fd2e5bba940d09
[exec] Executing: cmd /s /c ""c:\Progra~1\Python311\Scripts\pygmentize.exe" "-L" "lexer"" 2>&1
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-86fd2e5bba940d09/sb-stderr"
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-86fd2e5bba940d09/sb-stdout"
[exec] Removed directory "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-86fd2e5bba940d09"
[exec] Creating base path C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-237f871e31353545
[exec] Executing: cmd /s /c ""c:\Progra~1\Python311\Scripts\pygmentize.exe" "-l" "powershell" "-f" "html" "-O" "cssclass=mw-highlight,encoding=utf-8" "file""
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-237f871e31353545/file"
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-237f871e31353545/sb-stderr"
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-237f871e31353545/sb-stdout"
[exec] Removed directory "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-237f871e31353545"
[objectcache] fetchOrRegenerate(global:highlight:1e04b7e8e2e671872099e468f594fa58): miss, new value computed
[exec] Creating base path C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-5a0641ea93a9910c
[exec] Executing: cmd /s /c ""c:\Progra~1\Python311\Scripts\pygmentize.exe" "-l" "bash" "-f" "html" "-O" "cssclass=mw-highlight,encoding=utf-8" "file""
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-5a0641ea93a9910c/file"
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-5a0641ea93a9910c/sb-stderr"
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-5a0641ea93a9910c/sb-stdout"
[exec] Removed directory "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-5a0641ea93a9910c"
[objectcache] fetchOrRegenerate(global:highlight:79a0bec1f4c29b0a4e1f837a4b70f4a9): miss, new value computed
[DBConnection] Wikimedia\Rdbms\LoadBalancer::getLocalConnection: reused a connection for local/0
[DBQuery] LCStoreDB::get [0s] SELECT lc_value FROM `l10n_cache` WHERE lc_lang = 'sv' AND lc_key = 'messages:syntaxhighlight-error-category' LIMIT 1																									
[DBConnection] Wikimedia\Rdbms\LoadBalancer::getLocalConnection: reused a connection for local/0
[DBQuery] LCStoreDB::get [0s] SELECT lc_value FROM `l10n_cache` WHERE lc_lang = 'sv' AND lc_key = 'linkPrefixExtension' LIMIT 1
[DBConnection] Wikimedia\Rdbms\LoadBalancer::getLocalConnection: reused a connection for localAutoCommit/0

When swapping the yaml for bash it processes correctly and doesn't throw errors and doesn't get the "Pages with syntax highlighting errors". It now runs pygmentize five times, with the last working bash-block.

[DBQuery] MediaWiki\Storage\SqlBlobStore::fetchBlobs [0s] SELECT old_id,old_text,old_flags FROM `text` WHERE old_id = 1823
[objectcache] fetchOrRegenerate(global:SqlBlobStore-blob:hkr_mediawiki:tt%3A1823): miss, new value computed
[exec] Creating base path C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-c3bb7d17062047d8
[exec] Executing: cmd /s /c ""c:\Progra~1\Python311\Scripts\pygmentize.exe" "-V"" 2>&1
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-c3bb7d17062047d8/sb-stderr"
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-c3bb7d17062047d8/sb-stdout"
[exec] Removed directory "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-c3bb7d17062047d8"
[exec] Creating base path C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-0484336c3f645690
[exec] Executing: cmd /s /c ""c:\Progra~1\Python311\Scripts\pygmentize.exe" "-L" "lexer"" 2>&1
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-0484336c3f645690/sb-stderr"
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-0484336c3f645690/sb-stdout"
[exec] Removed directory "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-0484336c3f645690"
[exec] Creating base path C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-0b05e1edd661e368
[exec] Executing: cmd /s /c ""c:\Progra~1\Python311\Scripts\pygmentize.exe" "-l" "powershell" "-f" "html" "-O" "cssclass=mw-highlight,encoding=utf-8" "file""
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-0b05e1edd661e368/file"
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-0b05e1edd661e368/sb-stderr"
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-0b05e1edd661e368/sb-stdout"
[exec] Removed directory "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-0b05e1edd661e368"
[objectcache] fetchOrRegenerate(global:highlight:1e04b7e8e2e671872099e468f594fa58): miss, new value computed
[exec] Creating base path C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-d08c021bfe1b0311
[exec] Executing: cmd /s /c ""c:\Progra~1\Python311\Scripts\pygmentize.exe" "-l" "bash" "-f" "html" "-O" "cssclass=mw-highlight,encoding=utf-8" "file""
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-d08c021bfe1b0311/file"
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-d08c021bfe1b0311/sb-stderr"
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-d08c021bfe1b0311/sb-stdout"
[exec] Removed directory "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-d08c021bfe1b0311"
[objectcache] fetchOrRegenerate(global:highlight:79a0bec1f4c29b0a4e1f837a4b70f4a9): miss, new value computed
[exec] Creating base path C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-90a3aca3d2df8f1f
[exec] Executing: cmd /s /c ""c:\Progra~1\Python311\Scripts\pygmentize.exe" "-l" "bash" "-f" "html" "-O" "cssclass=mw-highlight,encoding=utf-8,linenos=inline,hl_lines=4" "file""
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-90a3aca3d2df8f1f/file"
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-90a3aca3d2df8f1f/sb-stderr"
[exec] Removed file "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-90a3aca3d2df8f1f/sb-stdout"
[exec] Removed directory "C:\WINDOWS\TEMP\mwtmp-IUSR/shellbox-90a3aca3d2df8f1f"
[objectcache] fetchOrRegenerate(global:highlight:3ad02a4ec124ea3009c02acf078da02e): miss, new value computed
[DBConnection] Wikimedia\Rdbms\LoadBalancer::getLocalConnection: reused a connection for local/0
[DBQuery] LCStoreDB::get [0s] SELECT lc_value FROM `l10n_cache` WHERE lc_lang = 'sv' AND lc_key = 'linkPrefixExtension' LIMIT 1
[DBConnection] Wikimedia\Rdbms\LoadBalancer::getLocalConnection: reused a connection for localAutoCommit/0

I'm so out of ideas.

What do you think?

Reply to "Some lexers work, others not"

SyntaxHighlight for mw templates

Juandev (talkcontribs)

Which language to use, to get best highlight of MediaWiki templates?

Want (talkcontribs)
PerfektesChaos (talkcontribs)

Sorry, no “best solution” for now.

  • Someone would need to create a MediaWiki “lexer” and upload it to upstream (3rd party software). One year later our {{ and [[ and {{{ stuff will be rendered nicely.
Reply to "SyntaxHighlight for mw templates"

1.38.1 - Pygments Initialization Error

6 (talkcontribs)

I have two instances of Mediawiki running on Windows Server 2016. One instance has been running for a few years and I am working on updating mediawiki from 1.35.1 (old) to 1.38.1 (new) in a separate instance to avoid breaking the production environment before it is functional. Example url on the same server.

  • server/wiki/index.php?title=Main_Page (1.35.1)
  • server/wiki1.38.1/index.php?title=Main_Page (1.38.1)

I've had this python extension installed and running for the current 1.35.1 instance for a long time. In the new 1.38.1 instance I have specified $wgPygmentizePath in the LocalSettings.php for Mediawiki as the instructions specify, pointing to the same location as the current 1.35.1 path. This code exists in both LocalSettings.php files.

# Pygments for SyntaxHighlight
$wgPygmentizePath = "E:/Program Files (x86)/Python/Scripts/pygmentize.exe";

I also tried below, and both paths seem to call pygmentize.exe and generate the error. If I comment out the $wgPygmentizePath the page loads fine but there is no syntax highlighting.

# Pygments for SyntaxHighlight
$wgPygmentizePath = "E:\\Program Files (x86)\\Python\\Scripts\\pygmentize.exe";

Each instance is pointed to its own MySQL database instance but other than that everything else is the same since these are both running on the same server. Same version of php, same version of python, same version of pygments, there is no special IIS application pool settings. So far the only difference should be the newly installed version of mediawiki (1.38.1). When I visit any page that calls <syntaxhighlight> I get this error now in 1.38.1... while for the same page in 1.35.1 pygmentize continues to execute and render fine.

[ba1074563ef8de0d563c6bb9] /wiki1.38.1/index.php/Automation_Logon_Script MediaWiki\SyntaxHighlight\PygmentsException: Fatal Python error: _Py_HashRandomization_Init: failed to get random numbers to initialize Python Python runtime state: preinitialized Backtrace: from E:\inetpub\wwwroot\wiki1.38.1\extensions\SyntaxHighlight_GeSHi\includes\Pygmentize.php(87) #0 E:\inetpub\wwwroot\wiki1.38.1\includes\libs\objectcache\BagOStuff.php(202): MediaWiki\SyntaxHighlight\Pygmentize::MediaWiki\SyntaxHighlight{closure}(integer) #1 E:\inetpub\wwwroot\wiki1.38.1\extensions\SyntaxHighlight_GeSHi\includes\Pygmentize.php(91): BagOStuff->getWithSetCallback(string, integer, Closure) #2 E:\inetpub\wwwroot\wiki1.38.1\extensions\SyntaxHighlight_GeSHi\includes\Pygmentize.php(156): MediaWiki\SyntaxHighlight\Pygmentize::getVersion() #3 E:\inetpub\wwwroot\wiki1.38.1\extensions\SyntaxHighlight_GeSHi\includes\SyntaxHighlight.php(58): MediaWiki\SyntaxHighlight\Pygmentize::getLexers() #4 E:\inetpub\wwwroot\wiki1.38.1\extensions\SyntaxHighlight_GeSHi\includes\SyntaxHighlight.php(190): SyntaxHighlight::getLexer(string) #5 E:\inetpub\wwwroot\wiki1.38.1\extensions\SyntaxHighlight_GeSHi\includes\SyntaxHighlight.php(315): SyntaxHighlight::highlightInner(string, string, array) #6 E:\inetpub\wwwroot\wiki1.38.1\extensions\SyntaxHighlight_GeSHi\includes\SyntaxHighlight.php(132): SyntaxHighlight::highlight(string, string, array, Parser) #7 E:\inetpub\wwwroot\wiki1.38.1\includes\parser\Parser.php(3979): SyntaxHighlight::parserHook(string, array, Parser, PPFrame_Hash) #8 E:\inetpub\wwwroot\wiki1.38.1\includes\parser\PPFrame_Hash.php(353): Parser->extensionSubstitution(array, PPFrame_Hash) #9 E:\inetpub\wwwroot\wiki1.38.1\includes\parser\Parser.php(2932): PPFrame_Hash->expand(PPNode_Hash_Tree, integer) #10 E:\inetpub\wwwroot\wiki1.38.1\includes\parser\Parser.php(1579): Parser->replaceVariables(string) #11 E:\inetpub\wwwroot\wiki1.38.1\includes\parser\Parser.php(697): Parser->internalParse(string) #12 E:\inetpub\wwwroot\wiki1.38.1\includes\content\WikitextContentHandler.php(294): Parser->parse(string, Title, ParserOptions, boolean, boolean, integer) #13 E:\inetpub\wwwroot\wiki1.38.1\includes\content\ContentHandler.php(1705): WikitextContentHandler->fillParserOutput(WikitextContent, MediaWiki\Content\Renderer\ContentParseParams, ParserOutput) #14 E:\inetpub\wwwroot\wiki1.38.1\includes\content\Renderer\ContentRenderer.php(47): ContentHandler->getParserOutput(WikitextContent, MediaWiki\Content\Renderer\ContentParseParams) #15 E:\inetpub\wwwroot\wiki1.38.1\includes\Revision\RenderedRevision.php(267): MediaWiki\Content\Renderer\ContentRenderer->getParserOutput(WikitextContent, Title, integer, ParserOptions, boolean) #16 E:\inetpub\wwwroot\wiki1.38.1\includes\Revision\RenderedRevision.php(238): MediaWiki\Revision\RenderedRevision->getSlotParserOutputUncached(WikitextContent, boolean) #17 E:\inetpub\wwwroot\wiki1.38.1\includes\Revision\RevisionRenderer.php(221): MediaWiki\Revision\RenderedRevision->getSlotParserOutput(string, array) #18 E:\inetpub\wwwroot\wiki1.38.1\includes\Revision\RevisionRenderer.php(158): MediaWiki\Revision\RevisionRenderer->combineSlotOutput(MediaWiki\Revision\RenderedRevision, array) #19 [internal function]: MediaWiki\Revision\RevisionRenderer->MediaWiki\Revision{closure}(MediaWiki\Revision\RenderedRevision, array) #20 E:\inetpub\wwwroot\wiki1.38.1\includes\Revision\RenderedRevision.php(200): call_user_func(Closure, MediaWiki\Revision\RenderedRevision, array) #21 E:\inetpub\wwwroot\wiki1.38.1\includes\poolcounter\PoolWorkArticleView.php(137): MediaWiki\Revision\RenderedRevision->getRevisionParserOutput() #22 E:\inetpub\wwwroot\wiki1.38.1\includes\poolcounter\PoolCounterWork.php(162): PoolWorkArticleView->doWork() #23 E:\inetpub\wwwroot\wiki1.38.1\includes\page\ParserOutputAccess.php(302): PoolCounterWork->execute() #24 E:\inetpub\wwwroot\wiki1.38.1\includes\page\Article.php(702): MediaWiki\Page\ParserOutputAccess->getParserOutput(WikiPage, ParserOptions, MediaWiki\Revision\RevisionStoreCacheRecord, integer) #25 E:\inetpub\wwwroot\wiki1.38.1\includes\page\Article.php(517): Article->generateContentOutput(User, ParserOptions, integer, OutputPage, array) #26 E:\inetpub\wwwroot\wiki1.38.1\includes\actions\ViewAction.php(80): Article->view() #27 E:\inetpub\wwwroot\wiki1.38.1\includes\MediaWiki.php(544): ViewAction->show() #28 E:\inetpub\wwwroot\wiki1.38.1\includes\MediaWiki.php(321): MediaWiki->performAction(Article, Title) #29 E:\inetpub\wwwroot\wiki1.38.1\includes\MediaWiki.php(910): MediaWiki->performRequest() #30 E:\inetpub\wwwroot\wiki1.38.1\includes\MediaWiki.php(564): MediaWiki->main() #31 E:\inetpub\wwwroot\wiki1.38.1\index.php(53): MediaWiki->run() #32 E:\inetpub\wwwroot\wiki1.38.1\index.php(46): wfIndexMain() #33 {main}

Appreciate any ideas, I am not sure where to look.

Tystnaden (talkcontribs)

What version of Python do you have installed on the system? (talkcontribs)
  • python 3.9.1
  • pygments 2.12
  • php 7.4.14
  • mysql 5.7


Tystnaden (talkcontribs)

Is there some reason why you cannot use the Pygments which is bundled with the extension? I don't run windows, but I would expect the extension to work out of the box.

Tystnaden (talkcontribs)

Note that in MW 1.38.1 the extension has Pygments 2.11.2 bundled.

SeelTeam6 (talkcontribs)


->environment( [ 'SYSTEMROOT' => 'C:\Windows', ])

under each self::boxedCommand in includes/pygmentize.php seems to have fixed the problem for me.

I'm using the non-bundled pygments on windows server 2012, mediawiki 1.38.1, so similar situation to you. Hope this helps!

Reply to "1.38.1 - Pygments Initialization Error"