A MediaWiki extension to use the client-side syntax highlighter highlight.js
License: GNU Affero General Public License v3.0
JavaScript 27.20%PHP 64.31%CSS 8.49%
highlightjs_integration's Introduction
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:
https://www.mediawiki.org/wiki/Extension:Highlightjs_Integration
== Requirements ==
This version of the extension has been tested with highlight.js 11.5.1 and
MediaWiki 1.35.6.
== Installation ==
Add this line to your LocalSettings.php:
wfLoadExtension( 'Highlightjs_Integration' );
This extension will use a bundled copy of highlight.js 11.5.1 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/MediaWiki/HighlightJS/highlight' folder.
=== Bug Uncaught SyntaxError: unterminated regular expression literal ===
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.
== Usage ==
On the wiki page, you can use "syntaxhighlight" or "source" elements:
<syntaxhighlight>
<?php
// some php code
</syntaxhighlight>
== Parameters ==
* lang; Defines the language.
* inline; The 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>