Skip to content

Latest commit

 

History

History
355 lines (315 loc) · 8.35 KB

README.mediawiki

File metadata and controls

355 lines (315 loc) · 8.35 KB

Table of Contents

MediaWiki-SyntaxHighlight

This MediaWiki extension adds syntaxhighlight tag that is implemented using highlight.js library.

Requirements

  • MediaWiki 1.17 or above.

Installation

Step 1: Downloading

You can download the snapshot zip file and extract the files to your extensions directory. For example using wget and unzip tools:

cd /tmp
wget https://github.com/unikum/MediaWiki-SyntaxHighlight/archive/master.zip
unzip master.zip -d $WIKIROOT/extensions/SyntaxHighlight

This extention already include latest version of the highlight.js library which include all supported languages. You can also download highlight.js library with soppurt only a needed languages from this page. Check a needed languages and press "Download" button. Then extract highlight.zip to SyntaxHighlight/highlight.js directory.

Step 2: Installation

Add this line to the end of your LocalSettings.php:

require_once "$IP/extensions/SyntaxHighlight/SyntaxHighlight.php";

Installation can now be verified through Special:Version page on your wiki.

Configuration

You can specify highlight style by $wgSyntaxHighlightStyle in your LocalSettings.php:

$wgSyntaxHighlightStyle = 'xcode';
require_once "$IP/extensions/SyntaxHighlight/SyntaxHighlight.php";

You should put this line before require_once line.

By default highlight.js buileded for support only a common languages: Apache, Bash, C++, C#, CoffeeScript, CSS, Diff, HTTP, Ini file, Java, JavaScript, JSON, Markdown, Makefile, Nginx, ObjectiveC, Perl, PHP, Python, Ruby, SQL, XML.

If you want use an additional languages you should specify it with $wgSyntaxHighlightAdditionalLanguages option.

$wgSyntaxHighlightAdditionalLanguages = array('lua', 'r', 'tex');
require_once "$IP/extensions/SyntaxHighlight/SyntaxHighlight.php";

You should put this line before require_once line.

Usage

On the wiki page, you can now use "syntaxhighlight" elements:

<syntaxhighlight lang="php">
<?php
    $v = "string";    // sample initialization
?>
html text
<?
    echo $v;         // end of php code
?>
</syntaxhighlight>

You can specify language by lang="" parameter. If lang parameter isn't defined language will be detected automaticy.

Supported languages

These are the languages that can be used in the lang parameter.

Code Language
1c 1C
actionscript ActionScript
apache Apache
applescript AppleScript
asciidoc AsciiDoc
autohotkey AutoHotkey
avrasm AVR Assembler
axapta Axapta
bash Bash
brainfuck Brainfuck
clojure Clojure
cmake CMake
coffeescript CoffeeScript
cpp C++
cs C#
css CSS
delphi Delphi
diff Diff
django Django
d D
dos DOS .bat
elixir Elixir
erlang Erlang
erlang-repl Erlang REPL
fix FIX
fsharp F#
glsl GLSL
go Go
haml Haml
handlebars Handlebars
haskell Haskell
http HTTP
ini Ini
java Java
javascript JavaScript
json JSON
lasso Lasso
lisp Lisp
livecodeserver LiveCode server and revIgniter
lua Lua
makefile Makefile
markdown Markdown
mathematica Mathematica
matlab Matlab
mel MEL
mizar Mizar
nginx Nginx
nix Nix
nsis NSIS
objectivec Objective C
ocaml OCaml
oxygene Oxygene
parser3 Parser3
perl Perl
php PHP
profile Python profile
protobuf Protocol Buffers
python Python
rib RenderMan RIB
r R
rsl RenderMan RSL
ruby Ruby
ruleslanguage Oracle Rules Language
rust Rust
scala Scala
scilab Scilab
scss SCSS
smalltalk Smalltalk
sql SQL
tex TeX
vala Vala
vbnet VB.NET
vbscript VBScript
vhdl VHDL
vim Vim Script
x86asm Intel x86 Assembly
xml HTML, XML

Theme Styles

These are the styles that can be used in the $wgSyntaxHighlightStyle extention parameter.

You can show this styles on live demo page.

Code Style Name
default Default
dark Dark
far FAR
idea IDEA
sunburst Sunburst
zenburn Zenburn
vs Visual Studio
ascetic Ascetic
magula Magula
github GitHub
googlecode Google Code
brown_paper Brown Paper
school_book School Book
ir_black IR Black
solarized_dark Solarized - Dark
solarized_light Solarized - Light
arta Arta
monokai Monokai
monokai_sublime Monokai Sublime
xcode XCode
pojoaque Pojoaque
rainbow Rainbow
tomorrow Tomorrow
tomorrow-night Tomorrow Night
tomorrow-night-bright Tomorrow Night Bright
tomorrow-night-blue Tomorrow Night Blue
tomorrow-night-eighties Tomorrow Night Eighties
railscasts Railscasts
obsidian Obsidian
docco Docco
mono-blue Mono Blue
foundation Foundation
atelier-dune.dark Atelier Dun - Dark
atelier-dune.light Atelier Dun - Light
atelier-forest.dark Atelier Forest - Dark
atelier-forest.light Atelier Forest - Light
atelier-heath.dark Atelier Heath - Dark
atelier-heath.light Atelier Heath - Light
atelier-lakeside.dark Atelier Lakeside - Dark
atelier-lakeside.light Atelier Lakeside - Light
atelier-seaside.dark Atelier Seaside - Dark
atelier-seaside.light Atelier Seaside - Light
paraiso.dark Paraiso - Dark
paraiso.light Paraiso - Light

License

This Extention licensed under GPL v2 License.

Installation from Git

Getting extension

You can use a Git clone tool to clone https://github.com/unikum/MediaWiki-SyntaxHighlight in the extensions directory of your wiki. For example using the Git command-line tool from wiki/extensions directory:

git clone https://github.com/unikum/MediaWiki-SyntaxHighlight SyntaxHighlight

Make sure the below control executes from within wiki/extensions/ folder. Otherwise you need to move this folder from current location to wiki/extensions folder using

mv <source> <destination>