Extension talk:SyntaxHighlight
Add topicPlease do not use this page to request support for specific languages or to report syntax highlighting errors. This extension relies on the Pygments library, which is not maintained by the MediaWiki developers. Any bug reports or feature requests related to the highlighting should be directed to the Pygments developers. |
Copy Tag
[edit]Just thought I would note here since this is a protected page. But for the navigator.clipboard to work, for the copy tag, the wiki must be using HTTPS, and the user must be connected using https as well. 2600:1004:B302:FF51:DC98:EFA4:CC86:4B9D 14:06, 14 January 2025 (UTC)
- Which I know is a standard nowadays, but just thought it would be a good note for private wiki’s that aren’t public facing 2600:1004:B302:FF51:DC98:EFA4:CC86:4B9D 14:10, 14 January 2025 (UTC)
Error category for every page
[edit]MediaWiki: 1.43.5
PHP: 8.2.28 (fpm-cgi)
Pygments: 2.19.2
SyntaxHighlight: 2.0
Every page, I use SyntaxHighlight on, get's added to the "syntax error category". Even if I use a simple example like
<syntaxhighlight lang="text"> test </syntaxhighlight>
If I use the example from the extensions page, the category is added too and there are no line numbers shown.
<syntaxhighlight lang="python" line> def quick_sort(arr): less = [] pivot_list = [] more = [] if len(arr) <= 1: return arr else: pass </syntaxhighlight>
Using debug mode I found the following lines:
[warning] Failed to invoke Pygments: Traceback (most recent call last): File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/data/vhosts/wiki-doku/extensions/SyntaxHighlight_GeSHi/includes/../pygments/pygmentize/__main__.py", line 4, in <module> File "/data/vhosts/wiki-doku/extensions/SyntaxHighlight_GeSHi/includes/../pygments/pygmentize/pygments/cmdline.py", line 21, in <module> File "/data/vhosts/wiki-doku/extensions/SyntaxHighlight_GeSHi/includes/../pygments/pygmentize/pygments/lexers/__init__.py", line 19, in <module> File "/data/vhosts/wiki-doku/extensions/SyntaxHighlight_GeSHi/includes/../pygments/pygmentize/pygments/plugin.py", line 35, in <module> ModuleNotFoundError: No module named 'importlib.metadata'
Could this be the reason? I am trying to install this package at the moment, but the server has no internet connection. So no idea if this will work.
Thx, Drhirn (talk) 14:47, 29 December 2025 (UTC)
- Your version of Python is too old for your version of Pygments. Try upgrading your Python to at least 3.8. * Pppery * it has begun 15:04, 29 December 2025 (UTC)
- This could prove difficult. But I'll try. Thanks for the tip! Drhirn (talk) 09:03, 30 December 2025 (UTC)
- If you are stuck on an unsupported version of Python for some reason there are two possible solutions. The first is to downgrade to an older version of the SyntaxHighlight extension. The Python 3.8 requirement comes from Pygments 2.18.0 which we introduced in June 2025.
- The second option would be to use the Docker container we produce for Wikimedia's content wikis to run the Pygments binary via Shellbox. There are basic instructions on setting up a wiki to use Shellbox for SyntaxHighlight at MediaWiki-Docker/Extension/SyntaxHighlight#Run from Shellbox container. The specifics about your Docker runtime would likely be different, but the core workflow of running
docker-registry.wikimedia.org/httpd-fcgi:latestplusdocker-registry.wikimedia.org/wikimedia/mediawiki-libs-shellbox:syntaxhighlight83would be the same outside of a MediaWiki-Docker development environment. -- BDavis (WMF) (talk) 20:55, 5 January 2026 (UTC)
- If you are stuck on an unsupported version of Python for some reason there are two possible solutions. The first is to downgrade to an older version of the SyntaxHighlight extension. The Python 3.8 requirement comes from Pygments 2.18.0 which we introduced in June 2025.
- This could prove difficult. But I'll try. Thanks for the tip! Drhirn (talk) 09:03, 30 December 2025 (UTC)