===== Syntax Highlighting for Code Blocks===== >>==See Wikka in action:== ~-""Adding a code block"" {{image url="images/action/qt.gif" alt="quicktime icon" title="Wikka clips"}} ==See also:== ~-Development: [[http://wikkawiki.org/WikkaGeshiIntegration | WikkaGeshiIntegration]]. ~-[[ThirdPartyInfo | Third-party software bundled with Wikka]] ~-FormattingRules for the usage >>{{since version="1.1.6.0" align="left"}}This is the documentation page for the syntax highlighter. {{image alt="Code highlighting sample" title="GeSHi support" url="images//features/code_highlighting.jpg"}} ::c:: [[http://qbnz.com/highlighter/ | GeSHi]] is now hooked into Wikka. Usage: ##""%%(formatter[;line-number][;filename]) code %%""## ==Line-numbers== If ##geshi_line_numbers##in the ConfigurationOptions is enabeld, simply add a ##;line-number## after the language formatter to display line-numbers starting at ##line-number##. ~##""%%(php;""{{color c="red" text="15"}}"")
<?php
echo "Hello, World!";
?>
%%""## %%(php;15) %% ==Setting a file name for download== If you specify a ##filename##, this will be used for downloading the code. ~##""%%(php;15;""{{color c="red" text="test.php"}}"")
<?php
echo "Hello, World!";
?>
%%""## %%(php;15;test.php) %% ==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 == |?|List of available code formatters {{since display="inline" version="1.1.6.4"}}|| || |=|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 is not handled by GeSHi, but by a Wikka handler: [[FormatterCSV]]{{since version="1.4.2" display="inline"}} ==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 [[http://qbnz.com/highlighter/ | GeSHi]]== ""%%(php;1) PHP code with line-numbers%%:"" %%(php;1) %% ""%%(css) CSS code%%"" %%(css) 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; } %% ""%%(javascript;129) JavaScript code starting on line 129%%"" %%(javascript;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%%:"" %%(php;1;test.php) %% ==Wikka built-in highlighter== The built-int highlighter does not supported line numbering and is maintained for backwards-compatibility. ""%%(ini) INI file contents%%:"" %%(ini) ; 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 %% ""%%(email) Email message%%:"" %%(email) Hi! >>>> 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