Extension:SyntaxHighlight GeSHi

From WikiVet English
Jump to navigation Jump to search
Help:ContentsHelp Banner.png
EXTENSIONS


Introduction

The <syntaxhighlight> tags allow the display of preformatted code modules but in addition they add coloring according to the code language settings. Like the <pre> tags and the <poem> tags, they preserve white space, that is, they depict the code module exactly as it was typed.

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>

show:

<syntaxhighlight lang="php"> <?php

   $v = "string";    // sample initialization

?> html text <?

   echo $v;         // end of php code

?> </syntaxhighlight>

Parameters

lang="??"
Defines what programming language the source code is using. This affects how the extension highlights the source code. See the section "Supported languages" in this page for details of supported languages.
line="GESHI_NORMAL_LINE_NUMBERS|GESHI_FANCY_LINE_NUMBERS"
Type of line numbering to use (default is no line numbering). Corresponds to enable_line_numbers the flag in GeSHi.
line start="??"
Use together with the parameter "line". Define the start number of the line. If you type line start="55", it will start counting at 55, then 56,57,58... and so on. Corresponds to start_line_numbers_at method on GeSHi
highlight="??"
Specifies which line is highlighted. Note that the parameter line start="??" doesn't affect how it counts the lines.
enclose="??"
Specifies what container is used to enclose the source code. Takes values "pre" (default value), "div", "none". Corresponds to set_header_type method on GeSHi.
strict
Type the name of the parameter to enable the strict mode. Corresponds to enable_strict_mode method on GeSHi.


More Usage

When line numbering is added with line, long code lines will be wrapped. See the example below. When text is the selected language, and numbering is used, the behaviour resembles the use of pre tags with numbering and long-line wrapping.

The following example shows how to color an HTML code listing:

<syntaxhighlight lang="html4strict" line start="100" highlight="5">
HTML module goes here...
</syntaxhighlight>

A typical result is just: <syntaxhighlight lang="html4strict" line start="100" highlight="5">

Heading 1 Heading 2
This is cell 1 text This is cell 2 text

</syntaxhighlight>

Supported languages

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

Code Language
abap ABAP
actionscript ActionScript
ada Ada
apache Apache Configuration
applescript AppleScript
asm ASM
asp Active Server Pages (ASP)
autoit AutoIt
bash Bash
basic4gl Basic4GL
bf Brainfuck
blitzbasic Blitz BASIC
bnf Backus-Naur Form
c C
c_mac C (Mac)
caddcl AutoCAD DCL
cadlisp AutoLISP
cfdg CFDG
cfm ColdFusion Markup Language
cil Common Intermediate Language (CIL)
cobol COBOL
cpp-qt C++ (Qt toolkit)
cpp C++
csharp C#
css Cascading Style Sheets (CSS)
d D
delphi Delphi
diff Diff
div DIV
dos DOS batch file
dot DOT
eiffel Eiffel
fortran Fortran
freebasic FreeBASIC
genero Genero
gettext GNU internationalization (i18n) library
glsl OpenGL Shading Language (GLSL)
gml Game Maker Language (GML)
gnuplot gnuplot
groovy Groovy
haskell Haskell
hq9plus HQ9+
html4strict HTML
idl Uno IDL
ini INI
inno Inno
intercal INTERCAL
io Io
java Java
java5 Java(TM) 2 Platform Standard Edition 5.0
javascript JavaScript
kixtart KiXtart
klonec Klone C
klonecpp Klone C++
latex LaTeX
lisp Lisp
lolcode LOLCODE
lotusscript LotusScript
lua Lua
Code Language
m68k Motorola 68000 Assembler
make make
matlab MATLAB M
mirc mIRC scripting language
mxml MXML
mpasm Microchip Assembler
mysql MySQL
nsis Nullsoft Scriptable Install System (NSIS)
objc Objective-C
ocaml-brief OCaml
ocaml OCaml
oobas OpenOffice.org Basic
oracle8 Oracle 8 SQL
oracle11 Oracle 11 SQL
pascal Pascal
per per
perl Perl
php-brief PHP
php PHP
pixelbender Pixel Bender
plsql PL/SQL
povray Persistence of Vision Raytracer
powershell Windows PowerShell
progress OpenEdge Advanced Business Language
prolog Prolog
providex ProvideX
python Python
qbasic QBasic/QuickBASIC
rails Rails
reg Windows Registry
robots robots.txt
ruby Ruby
rsplus R/S+
sas SAS
scala Scala
scheme Scheme
scilab Scilab
sdlbasic SdlBasic
smalltalk Smalltalk
smarty Smarty
sql SQL
tcl Tcl
teraterm Tera Term
text Plain text
thinbasic thinBasic
tsql Transact-SQL
typoscript TypoScript
vb Visual Basic
vbnet VVisual Basic .NET
verilog Verilog
vhdl VHDL
vim Vimscript
visualfoxpro Visual FoxPro
visualprolog Visual Prolog
whitespace Whitespace
winbatch Winbatch
xml XML
xorg_conf Xorg.conf
xpp X++
z80 ZiLOG Z80 Assembler