Mediawiki extensions: syntaxhighlightgeshi

From wikinotes

Extension that enables syntax highlighting using python pygments.

Documentation

home https://www.mediawiki.org/wiki/Extension:SyntaxHighlight

Install

Install php requirements


First, verify the following php plugins are installed, and available.
These may be in your /usr/local/etc/php.ini, or they may be loaded from /usr/local/etc/php.d/*.conf files.

  • ext-18-session.ini
  • ext-20-ctype.ini
  • ext-20-curl.ini
  • ext-20-dom.ini
  • ext-20-fileinfo.ini
  • ext-20-filter.ini
  • ext-20-iconv.ini
  • ext-20-intl.ini
  • ext-20-json.ini
  • ext-20-mbstring.ini
  • ext-20-mysqli.ini
  • ext-20-openssl.ini
  • ext-20-phar.ini
  • ext-20-readline.ini
  • ext-20-sockets.ini
  • ext-20-xml.ini
  • ext-20-xmlreader.ini
  • ext-20-zlib.ini


Composer install

cd /usr/local/www/mediawiki/extensions/SyntaxHighlight_GeSHi
composer install

Set path to pygmentize (if reqd)

Syntaxhighlight-geshi ships with a vendored pygments library.
The permissions are incorrect, and it is hard-coded to use a `python3` executable.
If your OS does not provide this (ex: FreeBSD) you'll need to install pygments, and provide a path to it's executable.

pkg install py37-pygments
# /usr/local/www/mediawiki/LocalSettings.php

$wgPygmentizePath = "/usr/local/bin/pygmentize";

Troubleshooting

Logging

Add the following to your LocalSettings.php to enable logging.
This log will display syntaxhighlight errors, and the raised error.

$wgDebugLogFile = "/var/log/mediawiki/mediawiki.log";

You may also need to create the directory, and set it's permissions.

mkdir -p /var/log/mediawiki
chmown www:www /var/log/mediawiki