-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom lexer no longer worked in my computer. #360
Comments
If you check the log file, you'll see (on Windows)
Thus the culprit is the quotes around In example below a new boolean option % based on https://github.com/gpoore/minted/issues/176#issuecomment-695344998
\begin{filecontents}[noheader]{my_lexer.py}
from pygments.lexers.markup import TexLexer
from pygments.token import Keyword
class TexLexer2(TexLexer):
"""
Improved lexer for the TeX and LaTeX typesetting languages.
Character "@" is treated part of command names.
"""
TexLexer.tokens['root'][4] = (r'\\([a-zA-Z@]+|.)', Keyword, 'command')
\end{filecontents}
\documentclass{article}
\usepackage{minted}
\makeatletter
\ifwindows
\renewcommand{\minted@optlistcl@quote}[2]{%
\ifstrempty{#2}{\detokenize{#1}}{\detokenize{#1="#2"}}}
\else
\renewcommand{\minted@optlistcl@quote}[2]{%
\ifstrempty{#2}{\detokenize{#1}}{\detokenize{#1='#2'}}}
\fi
% similar to \minted@def@optcl@switch
\newcommand{\minted@def@optcl@novalue}[2]{%
\define@booleankey{minted@opt@g}{#1}%
{\minted@addto@optlistcl{\minted@optlistcl@g}{#2}{}%
\@namedef{minted@opt@g:#1}{true}}
{\@namedef{minted@opt@g:#1}{false}}
\define@booleankey{minted@opt@g@i}{#1}%
{\minted@addto@optlistcl{\minted@optlistcl@g@i}{#2}{}%
\@namedef{minted@opt@g@i:#1}{true}}
{\@namedef{minted@opt@g@i:#1}{false}}
\define@booleankey{minted@opt@lang}{#1}%
{\minted@addto@optlistcl@lang{minted@optlistcl@lang\minted@lang}{#2}{}%
\@namedef{minted@opt@lang\minted@lang:#1}{true}}
{\@namedef{minted@opt@lang\minted@lang:#1}{false}}
\define@booleankey{minted@opt@lang@i}{#1}%
{\minted@addto@optlistcl@lang{minted@optlistcl@lang\minted@lang @i}{#2}{}%
\@namedef{minted@opt@lang\minted@lang @i:#1}{true}}
{\@namedef{minted@opt@lang\minted@lang @i:#1}{false}}
\define@booleankey{minted@opt@cmd}{#1}%
{\minted@addto@optlistcl{\minted@optlistcl@cmd}{#2}{}%
\@namedef{minted@opt@cmd:#1}{true}}
{\@namedef{minted@opt@cmd:#1}{false}}
}
\minted@def@optcl@novalue{custom lexer}{-x}
\makeatother
\begin{document}
% runsystem(pygmentize -l 'tex' ...)
\begin{minted}[custom lexer=false]{tex}
% built-in tex lexer
\@namedef{cmd}{$a + \alpha$} x
\end{minted}
% runsystem(pygmentize -l 'my_lexer.py:TexLexer2' ... -x ...)
\begin{minted}[custom lexer]{my_lexer.py:TexLexer2}
% custom tex lexer which treats "@" as letter
\@namedef{cmd}{$a + \alpha$} y
\end{minted}
\end{document} |
minted 2.7 changed its behaviour to not allow for custom command line options, which broke our custom lexer definitions. Here is a similar bug reported: gpoore/minted#360. This commit adds a new minted command that allows custom lexers again.
I encountered the same issue. @muzimuzhi, would it make sense to contribute your |
minted 2.7 changed its behaviour to not allow for custom command line options, which broke our custom lexer definitions. Here is a similar bug reported: gpoore/minted#360. This commit adds a new minted command that allows custom lexers again.
minted 2.7 changed its behaviour to not allow for custom command line options, which broke our custom lexer definitions. Here is a similar bug reported: gpoore/minted#360. This commit adds a new minted command that allows custom lexers again.
minted 2.7 changed its behaviour to not allow for custom command line options, which broke our custom lexer definitions. Here is a similar bug reported: gpoore/minted#360. This commit adds a new minted command that allows custom lexers again.
minted 2.7 changed its behaviour to not allow for custom command line options, which broke our custom lexer definitions. Here is a similar bug reported: gpoore/minted#360. This commit adds a new minted command that allows custom lexers again.
minted 2.7 changed its behaviour to not allow for custom command line options, which broke our custom lexer definitions. Here is a similar bug reported: gpoore/minted#360. This commit adds a new minted option that allows custom lexers to work wiht newer texlive distributions. We also enhance our CI to check that the paper builds with old and new textlive distributions.
@tobiasgrosser Hi Tobias, I'm really happy my patch helps people with their documents, but first I think it has to be decided how In a more general way, I feel sth like |
Sure. Now, admittedly the fact that there are uses of this in the wild makes the discussion if the loss of the other feature is a bug or not more academic 🙂. In an optimal world the -x syntax would just continue to work. |
I'm having the same issue right now. A proper |
minted 2.7 changed its behaviour to not allow for custom command line options, which broke our custom lexer definitions. Here is a similar bug reported: gpoore/minted#360. This commit adds a new minted option that allows custom lexers to work wiht newer texlive distributions. We also enhance our CI to check that the paper builds with old and new textlive distributions.
|
I use a gams lexer (gams.py) in my project. Some months ago I found that my lexer no longer worked and it works before. At that time I thought it was a bug and maybe fixed. But recently I found that the same code can work on Overleaf so I think the problem doesn't lie in lexer. The simplest latex example would be
Error information:
I have updated all to the latest including
pygments
. I test installedpygments
withAnd it works perfectly.
The text was updated successfully, but these errors were encountered: