MediaWiki-Docker/Extension/SyntaxHighlight

From mediawiki.org

Download the SyntaxHighlight extension into extensions/ and enable it the usual way in LocalSettings.php:

wfLoadExtension( 'SyntaxHighlight_GeSHi' );

You will also need to customize the base MediaWiki image as described in Configuration_recipes/Customize_base_image to install the python3 package, which is relied upon by the extension to perform the syntax highlighting.

Install python3[edit]

In the MediaWiki root directory, create a file called python3.dockerfile, with the following contents:

FROM docker-registry.wikimedia.org/dev/buster-php81-fpm:1.0.1-s2
RUN apt-get update && apt-get install -y python3

Note you may need to change this php version to the most recent version found in docker-compose.yml

Then update docker-compose.override.yml to use this dockerfile when building the image for the mediawiki service:

services:
  mediawiki:
    build:
      context: .
      dockerfile: python3.dockerfile

Install Composer dependencies[edit]

If you haven't done so already,

mv composer.local.json-sample composer.local.json

This should include all the local extensions' composer.json files.

If you already have a composer.local.json, you can add this instead:

{
	"extra": {
		"merge-plugin": {
			"include": [
				"extensions/SyntaxHighlight_GeSHi/composer.json"
			]
		}
	}
}

Run:

docker compose exec mediawiki composer update

Rebuild[edit]

Finally, rebuild the mediawiki service and restart docker:

docker compose build
docker compose down
docker compose up -d