On Sat, Jul 26, 2025 at 02:42:59PM -0700, Raymond Toy wrote:
> I've been experimenting with using pygments to do syntax highlighting. This
> works fine, except I can't choose the style to use. I learned that pygments
> can output the CSS that controls the formatting and colors. For my example,
> I'm using |pygmentize -S style -f html| to get the CSS.
> 
> I added the CSS to the CSS file but the colors don't change. It turns out
> that what texinfo outputs from pygments is missing the class property for
> all of the pygments output.
> 
> For example, the html file contains
> 
> |<pre class="example-preformatted"> <div class="highlight"
> style="background: #f8f8f8"> <pre style="line-height: 125%;"> <span></span>(
> <span style="color: #800">%i</span> <span style="color: #666">1</span>)
> <span style="color: #BBB"> </span> |
> 
> But when I pass the same bit of maxima example code to pygments using
> |pygmentize -l maxima -f html|, I get
> 
> |<div class="highlight"> <pre> <span></span> <span class="p">(</span> <span
> class="no">%i</span> <span class="mi">1</span> <span class="p">) |
> 
> So the html from texinfo seems to have stripped out the classes used in the
> span elements.

There is no such change made to the resulting element.

> Or maybe texinfo run pygmentize with extra options?

Yes, pygmentize is especially called with -O noclasses=True, probably
because I wanted to avoid confusion with Texinfo classes.
 
> Anyway, since texinfo doesn't allow telling pygments what style to
> use, I was thinking of solving this by updating the CSS with the
> pgyments style that I want. This would also allow setting appropriate
> colors for dark mode.

There was a discussion of a possibility to call syntax highlighting more
flexibly, and have users specify the command-line of syntax highlighting
commands.  See this message, and, more generally this thread:
https://lists.gnu.org/archive/html/bug-texinfo/2024-11/msg00127.html

This is supposed to be implemented in the next release, maybe it could
fill your needs?

-- 
Pat

Reply via email to