Syntax Highlighting for Code Blocks
NOTE
This feature is available since:
WikkaWiki 1.1.6.0
WikkaWiki 1.1.6.0
GeSHi is now hooked into Wikka.
Usage: %%(formatter[;line-number][;filename]) code %%
Line-numbers
If geshi_line_numbersin the ConfigurationOptions is enabeld, simply add a ;line-number after the language formatter to display line-numbers starting at line-number.
%%(php;15)
<?php
echo "Hello, World!";
?>
%%
<?php
echo "Hello, World!";
?>
%%
- <?php
- echo "Hello, World!";
- ?>
Setting a file name for download
If you specify a filename, this will be used for downloading the code.
%%(php;15;test.php)
<?php
echo "Hello, World!";
?>
%%
<?php
echo "Hello, World!";
?>
%%
test.php (line 15)
- <?php
- echo "Hello, World!";
- ?>
Linking to online documention
If you click on a function name, you get to the entry of this function in the online manual of the language (only for some languages). You can try it out with the php-example below.Available formatters
GeSHi formatters
Language | Formatter | Language | Formatter | Language | Formatter |
---|---|---|---|---|---|
Actionscript | actionscript | ABAP | abap | ADA | ada |
Apache Log | apache | AppleScript | applescript | ASM | asm |
ASP | asp | AutoIT | autoit | Bash | bash |
BlitzBasic | blitzbasic | Basic4GL | basic4gl | bnf | bnf |
C | c | C for Macs | c_mac | C# | csharp |
C++ | cpp | C++ (+QT) | cpp-qt | CAD DCL | caddcl |
CadLisp | cadlisp | CFDG | cfdg | ColdFusion | cfm |
CSS | css | CSV † | csv | D | d |
Delphi | delphi | Diff-Output | diff | DIV | div |
DOS | dos | Dot | dot | Eiffel | eiffel |
Fortran | fortran | FreeBasic | freebasic | FOURJ\'s Genero 4GL | genero |
GML | gml | Groovy | groovy | Haskell | haskell |
HTML | html4strict | INI | ini | Inno Script | inno |
Io | io | Java 5 | java5 | Java | java |
Javascript | javascript | LaTeX | latex | Lisp | lisp |
Lua | lua | Matlab | matlab | mIRC Scripting | mirc |
Microchip Assembler | mpasm | Microsoft Registry | reg | Motorola 68k Assembler | m68k |
MySQL | mysql | NSIS | nsis | Objective C | objc |
OpenOffice BASIC | oobas | Objective Caml | ocaml | Objective Caml (brief) | ocaml-brief |
Oracle 8 | oracle8 | Pascal | pascal | Per (FOURJ\'s Genero 4GL) | per |
Perl | perl | PHP | php | PHP (brief) | php-brief |
PL/SQL | plsql | Python | phyton | Q(uick)BASIC | qbasic |
robots.txt | robots | Ruby on Rails | rails | Ruby | ruby |
SAS | sas | Scheme | scheme | sdlBasic | sdlbasic |
Smarty | smarty | SQL | sql | TCL/iTCL | tcl |
T-SQL | tsql | Text | text | thinBasic | thinbasic |
Unoidl | idl | VB.NET | vbnet | VHDL | vhdl |
Visual BASIC | vb | Visual Fox Pro | visualfoxpro | WinBatch | winbatch |
XML | xml | X++ | xpp | ZiLOG Z80 Assembler | z80 |
since 1.4.2
built-in:
- INI file
- email (with quotation indentation)
- php (taken care of by GeSHi, if present)
- code, unknown language, plain text
Note that GeSHi syntax highlighting takes precedence over built-in syntax highlighting.
Examples
highlighted with GeSHi
%%(php;1) PHP code with line-numbers%%:
- <?php
- $text = "Hello, World!";
- print $text;
- ?>
%%(css) CSS code%%
body {
font-family: "Trebuchet MS", Georgia, serif;
font-size: .9em;
line-height: 1.4em;
font-weight: normal;
color: #000000;
background-image: url(../images/wikkalight.jpg);
background-attachment: fixed;
background-repeat: no-repeat;
background-color: #000;
margin: 0px;
}
font-family: "Trebuchet MS", Georgia, serif;
font-size: .9em;
line-height: 1.4em;
font-weight: normal;
color: #000000;
background-image: url(../images/wikkalight.jpg);
background-attachment: fixed;
background-repeat: no-repeat;
background-color: #000;
margin: 0px;
}
%%(javascript;129) JavaScript code starting on line 129%%
- function fKeyDown()
- {
- if (event.keyCode == 9)
- {
- event.returnValue = false;
- document.selection.createRange().text = String.fromCharCode(9);
- }
- }
%%(php;1) PHP code with line-numbers and filename%%:
test.php (line 1)
- <?php
- $text = "Hello, World!";
- print $text;
- ?>
Wikka built-in highlighter
The built-int highlighter does not supported line numbering and is maintained for backwards-compatibility.
%%(ini) INI file contents%%:
; Menu specification file for Opera 7.0
[Version]
File Version=2
[Info] #background info
Name=Munin++ Menu
Description=Munin++ Menu
Author=NonTroppo (originally by Rijk van Geijtenbeek)
Version=1.9
[Version]
File Version=2
[Info] #background info
Name=Munin++ Menu
Description=Munin++ Menu
Author=NonTroppo (originally by Rijk van Geijtenbeek)
Version=1.9
%%(email) Email message%%:
Hi!
>>>> My Llama loves foot massage.
>>> You really think so?
>> Yes, I know he does.
>Are you sure?
Of course, yes!
Mr. Scruff
>>>> My Llama loves foot massage.
>>> You really think so?
>> Yes, I know he does.
>Are you sure?
Of course, yes!
Mr. Scruff
%%code%%:
int main(int arc,char **argv) { printf("Hello, %s! ", (argc>1) ? argv[1] : "World"); return 0; }
CategoryEN