Extension:GoogleCodePrettify

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
GoogleCodePrettify

Release status: stable

Implementation MyWiki
Description Adds syntaxhighlight tag using Google Code Prettify library.
Author(s) Akzhantalk
Latest version 0.4 (2012-06-09)
MediaWiki 1.17 and higher
License MIT
Download Project page

Git [Help]
Commit history
Note:
No localisation updates are provided by translatewiki.net.

Hooks used
BeforePageDisplay

ParserFirstCallInit

Translate the GoogleCodePrettify extension if possible

Check usage and version matrix; code metrics

This extension adds syntaxhighlight tag using Google Code Prettify library.

Installation[edit | edit source]

  • Clone repository of the extension into your extensions/GoogleCodePrettify directory.
cd $MEDIAWIKI_ROOT
git clone git://github.com/Undev/MediaWiki-GoogleCodePrettify.git extensions/GoogleCodePrettify
  • Add the following line to the bottom of LocalSettings.php
require_once ( "$IP/extensions/GoogleCodePrettify/GoogleCodePrettify.php" );

syntaxhighlight tag[edit | edit source]

Google Code Prettify automatically recognizes language of source code. But you can set it using lang attribute.

class attribute[edit | edit source]

You can add additional CSS class names to generated pre tags using class attribute. This is useful, for example, to add mw-collapsible class.

Configuration[edit | edit source]

Enable handling of source tag[edit | edit source]

Handling of source tag disabled by default and is not recommended.

You can override this behavior by setting in LocalSettings.php:

$wgGoogleCodePrettifyAllowSourceTag = true;

Enable handling of shl tag[edit | edit source]

Handling of shl tag disabled by default.

You can override this behavior by setting in LocalSettings.php:

$wgGoogleCodePrettifyAllowShlTag = true;

Additional languages[edit | edit source]

By default GoogleCodePrettify enables these languages:

  • C and friends.
  • Java.
  • Python.
  • Bash.
  • SQL.
  • HTML.
  • XML.
  • CSS.
  • JavaScript.
  • Makefiles.
  • Ruby.
  • PHP.
  • Awk.
  • Perl.
  • YAML.

You can add or remove supported languages by changing of global $wgGoogleCodePrettifyAdditionalLanguages array variable.

See also[edit | edit source]