Changes

Jump to navigation Jump to search
14 bytes added ,  14:03, 12 May 2007
== Writing a parser/formatter ==
It is not difficult at all to write a little parser which takes as it its input your source file and gives in output a .tex file containing the code plus the opportune commands for colorization. You can then include the resulting .tex file in the global ConTeXt document file.
As an example, [http://www.cirma.unito.it/andrea/sw/sc/scToConTeXt.py this] is a Python script for the SuperCollider language, which has a Smalltalk-like syntax.
Basically, the idea is to envelope each item to be colorized inside a /BTEX /ETEX block.
Note that inside the block the text is no more verbatim, so you have to define some string replacement for special characters (e.g. _, %, $ etc).
The problem of the slash is solved here by wrapping the character within a type command. The example uses some definitions (explained before) which have to be put in the global ConTeXt file
<texcode>
89

edits

Navigation menu