Hi,
I use 'lgrind' to format my 'source code' (C, python, sricpts, etc.). I
like the 'layout' (highlighting, line numbering...). Is there something
equivalent (or better :) in/for ConTeXt?
--
Andre van der Vlies
Andre van der Vlies wrote:
Hi, I use 'lgrind' to format my 'source code' (C, python, sricpts, etc.). I like the 'layout' (highlighting, line numbering...). Is there something equivalent (or better :) in/for ConTeXt?
I personally do not know of anything that is comparable right away, but I could be wrong. Side note: I looked at the source of lgrind and it looks rather simple, so it may be possible to replace the lgrind executable with a perl (or ruby) script that can be targeted at ConTeXt as well as LaTeX. Taco
Taco Hoekwater said:
Side note: I looked at the source of lgrind and it looks rather simple, so it may be possible to replace the lgrind executable with a perl (or ruby) script that can be targeted at ConTeXt as well as LaTeX.
Mkee, but I'll need to know what to produce (even the LaTeX ouput looks
obscure to me); and I'll do it in python...
--
Andre van der Vlies
At 01:44 AM 9/13/2005, Taco Hoekwater wrote:
Andre van der Vlies wrote:
I use 'lgrind' to format my 'source code' (C, python, sricpts, etc.). I like the 'layout' (highlighting, line numbering...). Is there something equivalent (or better :) in/for ConTeXt?
I personally do not know of anything that is comparable right away, but I could be wrong.
I don't know of anything either. The LaTeX "listings" package is mostly just TeX at its core, so it's feasible to think of translating it -- but, even if it's only 5% LaTeX, that's still quite a lot of code, so it's still a good bit of work! The lgrind documentation does refer to an earlier tgrind which worked in Plain TeX; this might also work in ConTeXt.
Side note: I looked at the source of lgrind and it looks rather simple, so it may be possible to replace the lgrind executable with a perl (or ruby) script that can be targeted at ConTeXt as well as LaTeX.
In my opinion, that would be a useful thing, since lgrind itself is non-free. (Specifically, it's based on code with a "no-commercial" license.) An implementation that was careful to avoid any literal copying would get around that, and be a useful thing to have. Meanwhile, though, after looking through the code, I don't think there's actually much need to modify the executable. Lgrind mostly doesn't write LaTeX (which is why Andre found it so obscure) -- it writes TeXcode that uses its own simple commands, which are then defined in lgrind.sty. To use Lgrind in ConTeXt, one needs to translate the style file into a t-lgrind.tex, at which point the same Lgrind output files can be used in both systems. If you do re-implement it as a Python script, I would suggest keeping things similarly flexible, as it would be good to be able to use the re-implementation in LaTeX as well (due to the aforementioned license issues, an also just because it's convenient to be able to use the same system, for those of us likely to be writing papers in LaTeX and presentations in ConTeXt). - Brooks
For those who use it: what are the main highlights of lgrind? I only googled a bit, but I didn't install it yet, so I can't say anything about it yet. What do you think about idea of letting the code pass through vim? I already asked about it, but here are also some preliminary results: http://pub.mojca.org/tex/vim/fromlgrind/ Just to show that it's not that hard. I only deleted 70% of the 2html.vim and replaced one line or two. (To get really good results more has to be done of course, but for the beginning ...) I took the example assembler code from lgrind (vim support for assembler is not perfect as there are hundreds of assembler dialects, so please don't comment on bad recognition of syntax units or on my bad taste for style, but just to show some preliminary results and to be able to compare the results with those of lgrind). I produced HTML code out of the example and two PDFs, one with default original colors in my vim and one with some arbitrary style. OK, I admit, I cheated a bit when making PDFs (manually added header and footer, manually added the first space [\obeyspaces ignores the first ones], manually added colors), but this can be programmed. I don't know enough of ConTeXt internals to be able to start programming the support for it - I need syntax highlighting too, so I would be ready to invest some time and effort, but I can't do it without someone's help. However, supporing lgrind wouldn't be any easier I suppose, only the "vim" part is much more trivial than writing own parser and highlighting schemes for different languages. Vim is present on probably 99% of linux/unix systems and can be downloaded for Windows. The major problem is perhaps in achieving a kind of consistency (different vim settings on different computers, which have to be obeyed or discarded depending on user wish). The syntax for defining styles could look approximately like that: \setupsyntax[Identifier][color=darkblue,style=bold] \setupsyntax[Comment][color=gray,style=italic] Mojca
Mojca Miklavec wrote:
What do you think about idea of letting the code pass through vim? I already asked about it, but here are also some preliminary results: http://pub.mojca.org/tex/vim/fromlgrind/ Just to show that it's not that hard. I only deleted 70% of the 2html.vim and replaced one line or two. (To get really good results more has to be done of course, but for the beginning ...)
another alternative is scite, i wrote an xml exporter for that one that also exports the highlighting Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (5)
-
Andre van der Vlies
-
Brooks Moses
-
Hans Hagen
-
Mojca Miklavec
-
Taco Hoekwater