Andrew Senetar
7e04feff9f
First Version of the PrismHighlight Mediawiki extension. |
||
---|---|---|
prism | ||
.gitattributes | ||
.gitignore | ||
LICENSE.md | ||
PrismHighlight.base.php | ||
PrismHighlight.i18n.php | ||
PrismHighlight.php | ||
README.md | ||
init.js | ||
overrides.css |
README.md
PrismHighlight
Prism highlight is a syntax highlighting extension for Mediawiki which uses the Prism JavaScript syntax highlighter.
Installation
To install the extension clone the source into your extensions directory:
cd /path/to/wiki/extensions
git clone https://github.com/arsenetar/PrismHighlight.git
Alternatively you may download the source via zip.
To activate the extension open your LocalSettings.php
file and add the following:
require_once("$IP/extensions/PrismHighlight/PrismHighlight.php");
Configuration
The following are the configuration options for the Localsettings.php
file ( defaults shown ):
/**
* Theme to use
* options: dark, funky, okaidia, tomoorrow, twilight, false ( default )
* /
$wgPrismHighlightTheme = false;
/**
* Allow to highlight <source> tags
* options: true / false
*/
$wgPrismHighlightSource = true;
/**
* Plugins to use
* options: autolinker, file-highlight, ie8, line-highlight, line-numbers,
* show-invisibles, wpd
* note: autolinker and show-invisibles do not appear to work for some reason
*/
$wgPrismHighlightPlugins = array(
);
/**
* Languages to load
* options: bash, c, clike, coffeescript, cpp, css, css-extras, groovy,
* java, javascript, markup, php, python, scss, sql
*/
$wgPrismHighlightLanguages = array(
'bash',
'c',
'css',
'javascript',
'python',
'php',
'sql',
'markup',
);
Use
To use the syntax highlighter in wiki markup create the following:
<source>
//[...]
</source>
Place your code where //[...]
is.
Now the following parameters may be passed to the <source>
tag:
lang
orlanguage
- language to use (none specified uses markup)data-start
- the starting line number for numbering or highlightdata-lines
- the lines to highlightline-numbers
- used as a flag to specify line numbers should be used
Example
<source lang=php data-start=29 line-numbers>
foreach( $args as $key => $value ){
switch ($key) {
case 'lang':
case 'language':
$code_classes .= " language-$value";
break;
case 'class':
$code_classes .= " $value";
break;
case 'line-numbers':
$pre_args .= " class=$key";
break;
case 'data-start':
$pre_args .= " data-line-offset=$value"; //should make sure this is set
default;
$pre_args .= " $key=$value";
}
}
</source>