Help:Syntax Highlighting

From Rosetta Code
Revision as of 17:10, 11 June 2009 by rosettacode>Mwn3d (Updated)

This wiki supports syntax highlighting in code examples using the GeSHi project (version number shown below).

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:

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

looks like

<lang c>

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

</lang>

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/ (change version number to match the one below).

Ideally, one should also use the lang tags 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>

<lang list></lang>