bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: generic color support for `texinfo.tex`


From: Jean Abou Samra
Subject: Re: generic color support for `texinfo.tex`
Date: Mon, 20 Dec 2021 20:11:25 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.1



Le 20/12/2021 à 19:54, Patrice Dumas a écrit :
On Mon, Dec 20, 2021 at 05:17:46PM +0100, Jean Abou Samra wrote:
Le 20/12/2021 à 17:01, Patrice Dumas a écrit :
On Wed, Nov 24, 2021 at 03:17:22PM +0000, Werner LEMBERG wrote:
Hello Gavin,


For the LilyPond documentation we are going to use `pygments` to do
automatic colour highlighting of LilyPond snippets.  We also want to
support this feature in the PDF manuals.  To do so I ask you to apply
something like the following patch to make `@setcolor` work in
`@example` environments, too.
I don't know if it is relevant or not, but, for HTML, there is an init
file, tp/init/highligh_syntax.pm that uses source-highlight to highlight
@example blocks based on the language argument.

Thanks for the heads-up, I didn't know about that.
Unfortunately, it will not work for us, for several
reasons: first, we are still using texi2html, not
makeinfo (and even the decade-old texi2html 1.82!),
That's indeed an issue...

and second, the highlighting is done by Pygments,
not by source-highlight.
If it is possible to do something similar with Pygments than with 
source-highlight
it could easily be used as a replacement.  I do not know Pygments, some
functionalities from source-highlight that could be absent from Pygments
are a way to select fragments to be highlighted, as done with
source-highlight --line-range option, and also something that could be
unavailable could be something similar with source-highlight
--range-separator option which is also used to be able to easily get the
highlighted fragments.  However if those two functionalities are
present, it should probably be pretty easy to be able to use Pygments
too.


Thiking about it more, the main issue will be
how to call Pygments, which is a Python library.
Due to Python's interpreted nature, there is some
overhead of startup, around 0.05s -- which is
small, but starts to be noticeable if you have
hundreds of code snippets. If you find a way
to spawn a Python process and use the Python
API, that problem will be eliminated -- and it
will be trivial to implement equivalents to
--line-range and --range-separator. However, I
don't know about the implementation of makeinfo,
so I have no idea whether this kind of thing
is possible.

This is not problematic for us because our input
is already preprocessed by a Python script
(it's called lilypond-book and its main purpose
is to invoke LilyPond on the snippets and
insert @image commands).

Best,
Jean




reply via email to

[Prev in Thread] Current Thread [Next in Thread]