ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* lgrind...
@ 2005-09-13  8:08 Andre van der Vlies
  2005-09-13  8:44 ` lgrind Taco Hoekwater
       [not found] ` <36174.192.168.54.1.1126645119.squirrel@vandervlies.xs4all. nl>
  0 siblings, 2 replies; 8+ messages in thread
From: Andre van der Vlies @ 2005-09-13  8:08 UTC (permalink / raw)



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@vandervlies.xs4all.nl>
               Certifiable UNIX engineer
               Homepage: http://vandervlies.xs4all.nl/~andre
Key fingerprint = 397C 7479 67DB 9306 23DC B423 7B58 CD5A 6EFF 5CF8
--
    ()  ascii ribbon campaign - against html e-mail
    /\                        - against microsoft attachments
                              ^[^#]
--

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: lgrind...
  2005-09-13  8:08 lgrind Andre van der Vlies
@ 2005-09-13  8:44 ` Taco Hoekwater
  2005-09-13 15:09   ` lgrind Andre van der Vlies
  2005-09-13 18:24   ` lgrind Brooks Moses
       [not found] ` <36174.192.168.54.1.1126645119.squirrel@vandervlies.xs4all. nl>
  1 sibling, 2 replies; 8+ messages in thread
From: Taco Hoekwater @ 2005-09-13  8:44 UTC (permalink / raw)




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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: lgrind...
  2005-09-13  8:44 ` lgrind Taco Hoekwater
@ 2005-09-13 15:09   ` Andre van der Vlies
  2005-09-13 18:24   ` lgrind Brooks Moses
  1 sibling, 0 replies; 8+ messages in thread
From: Andre van der Vlies @ 2005-09-13 15:09 UTC (permalink / raw)



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 <andre@vandervlies.xs4all.nl>
               Certifiable UNIX engineer
               Homepage: http://vandervlies.xs4all.nl/~andre
Key fingerprint = 397C 7479 67DB 9306 23DC B423 7B58 CD5A 6EFF 5CF8
--
    ()  ascii ribbon campaign - against html e-mail
    /\                        - against microsoft attachments
                              ^[^#]
--

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: lgrind...
  2005-09-13  8:44 ` lgrind Taco Hoekwater
  2005-09-13 15:09   ` lgrind Andre van der Vlies
@ 2005-09-13 18:24   ` Brooks Moses
  2005-09-14 16:05     ` lgrind Mojca Miklavec
  1 sibling, 1 reply; 8+ messages in thread
From: Brooks Moses @ 2005-09-13 18:24 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: lgrind (An intro to LaTeX package conversion)
       [not found] ` <36174.192.168.54.1.1126645119.squirrel@vandervlies.xs4all. nl>
@ 2005-09-13 21:35   ` Brooks Moses
  2005-09-14  9:34     ` Andre van der Vlies
  0 siblings, 1 reply; 8+ messages in thread
From: Brooks Moses @ 2005-09-13 21:35 UTC (permalink / raw)


(Andre: I'm sending this reply back to the ConTeXt list, because I think a 
fair bit of my reply might be generally useful to other people who want to 
try to convert LaTeX packages to ConTeXt.  I hope that's ok!)

At 01:58 PM 9/13/2005, Andre van der Vlies wrote:
>Brooks Moses said:
> > 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.
>
>Hmmm, that sure sounds promising. I've just recently using ConTeXt, this
>week actually. I am trying to rebuild a, few paged, LaTeX document which
>is typical for me...
>
>I think that renaming the 'sty' file will not be enough :-/

Not really, no.  Though it's potentially a start.  What you'll need to do 
then is to translate all of the LaTeX bits in it to ConTeXt bits.

(Also, it may be easier to start with the lgrind.dtx file, since that has 
all the comments that explain what's going on.)

>Thus, I produce a t-lgrind.tex, which I can \input and henceforth use
>something like \plasterthis{fine.grind}?

I should perhaps have explained that more thoroughly.  ConTeXt has 
"modules", which are roughly equivalent to LaTeX's packages; the filename 
"t-lgrind.tex" indicates a module.  (Specifically, the "t-" prefix 
indicates that it's a "third-party module", which is everything other than 
the modules that are actually part of ConTeXt itself.)

Thus, you'd use it with \usemodule[lgrind] rather than \input.  It amounts 
to pretty much the same thing, except ConTeXt does keep track of things so 
as not to load it twice, and things like that.

One big difference is that LaTeX puts all package code in a \makeatletter / 
\makeatother block.  ConTeXt doesn't do this, so you need to put those in 
manually -- the ConTeXt equivalent is \unprotect / \protect (which also 
allow ! and ? in macro names, along with @).

>Or, am I on the wrong track???
>
>I sure need to to a lot of reading...

Feel free to ask questions, too!

Some information to get you started:

===== An introduction to translating packages to modules =====
(As exemplified by a detailed discussion of lgrind.dtx)

First, copy everything in lgrind.dtx from about line 609 ("Implementation 
of Lgrind") to the end of the file into t-lgrind.tex.

Put a \unprotect command at the beginning, and a \protect command at the 
end, so that you can use @ in macro names.

\newcommand and \renewcommand are LaTeX-specific.  The easiest way to deal 
with this is to simply replace it with TeX \def macros, though that loses 
the error messages that come from checking whether the command exists or not.

\DeclareOption is LaTeX's way of handling package options.  For a first 
pass, it's probably easiest to just delete these.  (Or, if you usually use 
the option, then include the option's code directly.)

All of the \sffamily, \rmfamily, \itshape, and other font formatting 
commands on lines 727-736 are LaTeX-specific; you can replace them with the 
ConTeXt equivalents, which are on a Wiki page on "Basic Text Formatting".

I'm not sure whether \normalfont (lines 893, 901, and so forth) is 
LaTeX-specific or not.  You might have to replace that with the ConTeXt 
equivalent.

At line 818, the "lgrind" environment is defined.  The \newenvironment 
command is definitely a LaTeXism; you'll want to replace that with 
definitions for \startlgrind and \stoplgrind.

The use of the minipage and figure environments in lines 1060 or so and 
later are going to require a bit of looking at to figure out how to best 
replace them with ConTeXt equivalents.  Luckily, it looks like these are 
some of the "advanced" bits, so you could just not worry about this until 
you've got the basic lgrind environment working.

And I think that should do it.  There may be a few other LaTeXisms in the 
file that I missed, but a bit of testing should find those....

===== end =====

Probably by the time you've done that, you'll have had quite a thorough 
introduction to ConTeXt!  :)

- Brooks

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: lgrind (An intro to LaTeX package conversion)
  2005-09-13 21:35   ` lgrind (An intro to LaTeX package conversion) Brooks Moses
@ 2005-09-14  9:34     ` Andre van der Vlies
  0 siblings, 0 replies; 8+ messages in thread
From: Andre van der Vlies @ 2005-09-14  9:34 UTC (permalink / raw)



Brooks Moses said:
> (Andre: I'm sending this reply back to the ConTeXt list, because I think a
> fair bit of my reply might be generally useful to other people who want to
> try to convert LaTeX packages to ConTeXt.  I hope that's ok!)
>

Yep. I just didn't want to contaminate the list with my ramblings...

>
> I should perhaps have explained that more thoroughly.  ConTeXt has
> "modules", which are roughly equivalent to LaTeX's packages; the filename
> "t-lgrind.tex" indicates a module.  (Specifically, the "t-" prefix
> indicates that it's a "third-party module", which is everything other than
> the modules that are actually part of ConTeXt itself.)
>

Ah! I thought it meant 'translated'....

> Thus, you'd use it with \usemodule[lgrind] rather than \input.  It amounts
> to pretty much the same thing, except ConTeXt does keep track of things so
> as not to load it twice, and things like that.
>
>
> Feel free to ask questions, too!
>

Thanx!

> Some information to get you started:
>

    [...stuff deleted...]

>
> Probably by the time you've done that, you'll have had quite a thorough
> introduction to ConTeXt!  :)
>

Nice! That's what I aiming at.

--
               Andre van der Vlies <andre@vandervlies.xs4all.nl>
               Certifiable UNIX engineer
               Homepage: http://vandervlies.xs4all.nl/~andre
Key fingerprint = 397C 7479 67DB 9306 23DC B423 7B58 CD5A 6EFF 5CF8
--
    ()  ascii ribbon campaign - against html e-mail
    /\                        - against microsoft attachments
                              ^[^#]
--

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: lgrind...
  2005-09-13 18:24   ` lgrind Brooks Moses
@ 2005-09-14 16:05     ` Mojca Miklavec
  2005-09-14 16:13       ` lgrind Hans Hagen
  0 siblings, 1 reply; 8+ messages in thread
From: Mojca Miklavec @ 2005-09-14 16:05 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: lgrind...
  2005-09-14 16:05     ` lgrind Mojca Miklavec
@ 2005-09-14 16:13       ` Hans Hagen
  0 siblings, 0 replies; 8+ messages in thread
From: Hans Hagen @ 2005-09-14 16:13 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-09-14 16:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-13  8:08 lgrind Andre van der Vlies
2005-09-13  8:44 ` lgrind Taco Hoekwater
2005-09-13 15:09   ` lgrind Andre van der Vlies
2005-09-13 18:24   ` lgrind Brooks Moses
2005-09-14 16:05     ` lgrind Mojca Miklavec
2005-09-14 16:13       ` lgrind Hans Hagen
     [not found] ` <36174.192.168.54.1.1126645119.squirrel@vandervlies.xs4all. nl>
2005-09-13 21:35   ` lgrind (An intro to LaTeX package conversion) Brooks Moses
2005-09-14  9:34     ` Andre van der Vlies

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).