I have managed to hack myself into it.
With
$ find / -mount -name "*latex*" 2>/dev/null
I have found the location of pygments.
The file lexers/_mapping.py
contains a line
'TexLexer': ('pygments.lexers.markup', 'TeX', ('tex', 'latex'), ('*.tex', '*.aux', '*.toc'), ('text/x-tex', 'text/x-latex')),
telling me that the lexer is contained in the file pygments/lexers/markup.py
and that the class is called TexLexer
.
I have copied the file to lexer/latex_atletter.py
in the directory of my LaTeX project and removed all unneeded classes from it so that only the TexLexer
class remains.
This class contains a line
(r'\\([a-zA-Z]+|.)', Keyword, 'command'),
I have added an @
to the allowed letters in the regex (and a comment at the end of the line that I have edited it).
From here I have learned how to use this custom lexer in my LaTeX document:
I have added
\def\mylatexlexer{lexer/latex_atletter.py:TexLexer -x}
\newmintedfile[inputlatex]{\mylatexlexer}{}
to the preamble and replaced every occurence of \inputminted{latex}
with \inputlatex
.
Now, commands containing an @ symbol are highlighted correctly.