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: Gavin Smith
Subject: Re: generic color support for `texinfo.tex`
Date: Wed, 24 Nov 2021 20:50:36 +0000

On Wed, Nov 24, 2021 at 3:17 PM Werner LEMBERG <wl@gnu.org> wrote:
> 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'm not sure why it's needed; could you send an example of the kind of
input you are trying to make work?

I am guessing that it is @setcolor with an argument inside of @example, like

@example
test
@setcolor{0.7 0.7 0.2}brown
@end example

This doesn't work, as you found out. To work around this, you can
define a macro:

@tex
\global\def\colorBrown{0.7 0.7 0.2}
@end tex

@example
test
@setcolor{@colorBrown}brown
@end example

This works because the catcode of the space is "fixed" at the time of
the macro definition.

(Obviously this should be conditional on TeX and probably PDF output
in your document, using @iftex and so on.)

Catcodes are a confusing part of texinfo.tex and I'd rather not have
to do anything to make them more complicated. I'm not convinced that
your change would always work; for example, if the @setcolor command
is nested inside the argument to another command, then it's possible
that spaces inside its argument have their catcodes fixed at the time
of that argument being read, depending on how the other command was
defined.

Do you think that the workaround I suggested would be good enough for
your purposes?

> It would be nice to have `@setcolor` as an 'official' command that
> also works with other output formats (for info, this would probably be
> a no-op), but we can live without that since we let `pygments`
> directly manipulate the HTML output.

Good to hear that you are managing to do syntax highlighting in HTML.
I don't have the time myself to implement @setcolor as an official
Texinfo command and I doubt whether it would be a good idea anyway. In
the case of syntax highlighting this seems something that is better
done automatically rather than something for users to put in their
documents explicitly.



reply via email to

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