This extension allows source code to be syntax highlighted on the wiki pages.
This README file might be out of date, have a look at the extension page for updated informations.
This version of the extension has been tested with highlight.js 11.7.0 and MediaWiki 1.39.3.
Add the following line to your LocalSettings.php file:
wfLoadExtension( 'Highlightjs_Integration' );This extension uses a bundled copy of highlight.js 11.7.0 with the common languages.
If you would like to use a different copy of the library, you can download it on the highlight.js website and replace the extensions/Highlightjs_Integration/highlight folder.
Some languages are not available in highlight.js but you can add external libraries to handle additional languages.
Here is the list of all supported languages, the ones with a package name are external which need to be installed.
Installation of the T-SQL language grammar for highlight.js:
- download the
tsql.min.jsandssms.min.cssfrom the highlightjs-tsql GitHub repo. - copy the files to the
extensions/Highlightjs_Integration/highlightfolder. - update the
extensions/Highlightjs_Integration/extension.jsonfile.
{
// ...
"ResourceModules": {
"ext.HighlightjsIntegration": {
"scripts": [
"highlight/highlight.min.js",
"highlight/tsql.min.js", // add the javascript file for the T-SQL language
"init.js"
],
"styles": [
"custom.css",
"highlight/styles/vs2015.min.css",
"ssms.min.css" // add the css file for the T-SQL language if any
]The load of the highlight.min.js script in this extension raises a syntax error.
As a workaround, the highlight.min.js script is loaded from the CDNJS url instead of the file provided with this extension.
On a mediawiki page, you can use syntaxhighlight or source tag:
<syntaxhighlight>
<?php
// some php code
</syntaxhighlight>langDefines the language.inlineThe source code should be inline as part of a paragraph.
<syntaxhighlight lang="php">
<?php
// some php code
</syntaxhighlight><syntaxhighlight lang="cs" inline>var c = new Class();</syntaxhighlight>