Open main menu

Changes

1,076 bytes added ,  13:24, 12 May 2007
you can go for another, less elegant, way to format your verbatim text, which can include all the discussed ConTeXt benefit.
It is not difficult at all to write a little parser which takes as it 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 file in the sourceglobal 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.
As an Fed with this source code contained in 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.file:
<context>
\stoptyping
</context>
 
 
the script outputs this tex code, which is written into a file contained in the same folder of the source file (named example.tex):
<texcode>
\stopSC
<texcode>
 
The example uses some definitions (explained before) which have to be put in the global ConTeXt file
 
<context>
\defineframedtext
[framedSC]
[framecolor=cirmaBlue,
strut=yes,
offset=2mm,
width=local,
align=right]
 
\definetyping[SC][option=commands,
tab=2,numbering=line,
before={\startframedSC},
after={\stopframedSC}]
</context>
 
also, the global ConTeXt file requires color definition, which are created following SuperCollider colorization scheme:
 
<context>
%% SC colors %%
\definecolor [SCwhite] [r=1.0, g=1.0, b=1.0]
\definecolor [SCblack] [r=0.0, g=0.0, b=0.0]
\definecolor [SCblue] [r=0.0, g=0.0, b=0.75]
\definecolor [SCred] [r=0.75, g=0.0, b=0.0]
 
\definecolor [SCgrey] [r=0.376, g=0.376, b=0.376]
\definecolor [SCgreen] [r=0.0, g=0.45, b=0.0]
</context>
You can then insert the tex
89

edits