gpoore / minted

minted is a LaTeX package that provides syntax highlighting using the Pygments library. Highlighted source code can be customized using fancyvrb.
1.75k stars 128 forks source link

custom pygments style detected but ignored only in minted #299

Closed zapashcanon closed 2 years ago

zapashcanon commented 3 years ago

Hi,

I'm running an up-to-date debian unstable. I installed base16-pygments by running pip3 install pygments-base16.

When I try the following: xelatex -shell-escape -halt-on-error main.tex on this file :

\documentclass[12pt]{article}

\usepackage{minted}
\usemintedstyle{base16-onedark}

\begin{document}
  \mintinline{ocaml}{let f x = Some x}
\end{document}

It produces a file with default minted color scheme. It doesn't use the specified base16-onedark.

If I change the name to something that doesn't exist like fjesfkljesklfjklesf, I have a proper error:

(./_minted-main/default-pyg-prefix.pygstyle)Could not find style module 'fjesfkljesklfjklesf'.
system returned with code 256

So, minted finds that my style exists but just seems to ignore it. So I asked myself : maybe the style is wrong ?

I tried to call pygments myself, using: pygmentize -f html -O full,style=base16-onedark -l ocaml -o out.html code.ml on this file:

let f x = Some x

I checked the result with xdg-open out.html and the color scheme is the right one.

OK, maybe minted is just ignoring all my styles ? So I changed the \usemintedstyle{base16-onedark} to \usemintedstyle{monokai} (monokai is installed by default with pygment on my system) and this one is working.

So for some reasons, minted knows that base16-onedark exists (otherwise it would fail saying it can't find it) but ignores it completely and I can't see why...

Everything works fine with pygmentize so I believe the issue comes from minted. Do you have any clue ?

Cheers.

gpoore commented 3 years ago

minted can't use any styles whose names contain characters besides a-z,A-Z, plus - and _. This ultimately goes back to the characters that LaTeX allows in (normal) macro names, plus a little customization. So the numbers in the style name are causing failures...I'm surprised this didn't result in an error message.

There is an existing issue (https://github.com/gpoore/minted/issues/294) that, when resolved, should fix this as well. I have no idea when that will be possible, however.

For now, your best option if you really need the alternate style is to create a custom copy with a name that doesn't involve numbers.

zapashcanon commented 2 years ago

Thanks @gpoore, @jfbu and @muzimuzhi ! :)