Help:Syntax Highlighting: Difference between revisions

From Rosetta Code
Content added Content deleted
(→‎Old style: Splitting list into columns)
(Fix example instructions, I don't think we need the old style example anymore)
Line 5: Line 5:
== New style ==
== New style ==


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


<pre>
<pre>
Line 31: Line 31:


It's in principle possible to write additional PHP files for unsupported languages and include them. Please contact one of the administrators for details.
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

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

That renders as

<c>
int main (int argc, char* argv[])
{
return 0;
}
</c>
<div style="clear: both; column-count: 3; -webkit-column-count:3; -moz-column-count:3"><lang list></lang></div>
<div style="clear: both; column-count: 3; -webkit-column-count:3; -moz-column-count:3"><lang list></lang></div>

Revision as of 20:31, 8 November 2009

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 <lang> 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.

<lang list></lang>