[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: generic color support for `texinfo.tex`
From: |
Werner LEMBERG |
Subject: |
Re: generic color support for `texinfo.tex` |
Date: |
Wed, 24 Nov 2021 22:21:53 +0000 (UTC) |
>> 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
Exactly.
> This doesn't work, as you found out.
Well, it works fine after applying the patch that was part of my last
e-mail.
> 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.
This is certainly a possibility.
> 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.
Care to cook up such a possibly failing example?
I can only say that the LilyPond documentation – I don't know whether
you have had ever a look – maxes out texinfo to the extreme, I would
say, and my patch seems to work just fine.
> Do you think that the workaround I suggested would be good enough
> for your purposes?
Maybe. However, it's not me who is working on pygments support, so I
can't tell right now.
>> 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.
As written in my last e-mail, I'm fine if this command stays private.
Werner