Help:Syntax Highlighting

From Rosetta Code
Revision as of 10:26, 9 July 2008 by rosettacode>Dirkt (Removed xfeeds tag)

This wiki supports syntax highlighting in code examples using the GeSHi project, at the time of writing this version 1.0.7.22.

(FIXME: How can one find out which version is currently really installed? Special:Version doesn't seem to list it).

At the moment, the wiki is in transition from old style to new style highlighting; old style highlighting will still be valid for some time.

New style

Code examples are enclosed by <code> tags. The lang argument selects the language used for highlighting. Example:

<code lang="C">
int main (int argc, char* argv[])
{
  return 0;
}
</code>

looks like

int main (int argc, char* argv[])
{
  return 0;
}

A list of supported languages, and their corresponding PHP files for GeSHi, can be found here: http://geshi.svn.sourceforge.net/viewvc/geshi/tags/RELEASE_1_0_7_22/geshi-1.0.X/src/geshi/

Ideally, one should also use the <code>-tags with an appropriate lang argument for languages that are not yet supported, because that will avoid additional editing if these languages will become supported in a future release of GeSHi.

It's in principle possible to write additional PHP files for unsupported languages and include them. Please contact one of the administrators for details.

Old style

Code examples are enclosed in tags named after the language, as in

<c>
int main (int argc, char* argv[])
{
  return 0;
}
</c>

That renders as

<c> int main (int argc, char* argv[]) {

 return 0;

} </c>

The available tags are (from Special:Version):

<actionscript-french>, <actionscript>, <ada>, <apache>, <applescript>, <asm>, <asp>, <bash>, <blitzbasic>, <caddcl>, <cadlisp>, <c_mac>, <c>, <cpp>, <csharp>, <css>, <delphi>, <diff>, <dos>, <d>, <eiffel>, <freebasic>, <gml>, <html4strict>, <ini>, <inno>, <java>, <javascript>, <lisp>, <lua>, <matlab>, <mpasm>, <mysql>, <nsis>, <objc>, <ocaml-brief>, <ocaml>, <oobas>, <oracle8>, <pascal>, <perl>, <php-brief>, <php>, <python>, <qbasic>, <ruby>, <scheme>, <sdlbasic>, <smarty>, <sql>, <vbnet>, <vb>, <vhdl>, <visualfoxpro>, <xml>