1
0
Форк 0
Go to file
Andrew Senetar 5f5e6a7e9a Merge pull request #1 from mrforsythexeter/master
Fix issue with all languages being set to "markup"
2016-11-27 19:03:02 -06:00
prism First Version ( v0.1 ) 2013-06-07 01:49:35 -04:00
.gitattributes First Version ( v0.1 ) 2013-06-07 01:49:35 -04:00
.gitignore First Version ( v0.1 ) 2013-06-07 01:49:35 -04:00
LICENSE.md First Version ( v0.1 ) 2013-06-07 01:49:35 -04:00
PrismHighlight.base.php Fix issue with all languages being set to "markup" 2016-11-22 10:21:49 +00:00
PrismHighlight.i18n.php First Version ( v0.1 ) 2013-06-07 01:49:35 -04:00
PrismHighlight.php First Version ( v0.1 ) 2013-06-07 01:49:35 -04:00
README.md Update README.md 2013-07-31 09:59:42 -04:00
init.js First Version ( v0.1 ) 2013-06-07 01:49:35 -04:00
overrides.css First Version ( v0.1 ) 2013-06-07 01:49:35 -04:00

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 or language - language to use (none specified uses markup)
  • data-start - the starting line number for numbering or highlight
  • data-lines - the lines to highlight
  • line-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>