summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-François B <jfbu@free.fr>2021-02-12 17:36:42 +0100
committerGitHub <noreply@github.com>2021-02-12 17:36:42 +0100
commitaffc26badce48f2d533e0b03218ad54c77781e57 (patch)
tree059319d134d5d791b6f3c8b6b218ca2043b1ad8d
parent68af5904f004e3c5460bde604de99a52f2ff124f (diff)
downloadpygments-git-affc26badce48f2d533e0b03218ad54c77781e57.tar.gz
LaTeX: use \@namedef (refactoring) (#1710)
$ latexdef @namedef \@namedef: macro:#1->\expandafter \def \csname #1\endcsname And the @ character is usable here in macro names (the variable with name definition is authorized to contain for example \PY@it) This makes the output shorter. It makes for a neater sphinxhighlight.sty...
-rw-r--r--pygments/formatters/latex.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/pygments/formatters/latex.py b/pygments/formatters/latex.py
index 22827be2..a72b6b04 100644
--- a/pygments/formatters/latex.py
+++ b/pygments/formatters/latex.py
@@ -321,8 +321,7 @@ class LatexFormatter(Formatter):
cp = self.commandprefix
styles = []
for name, definition in self.cmd2def.items():
- styles.append(r'\expandafter\def\csname %s@tok@%s\endcsname{%s}' %
- (cp, name, definition))
+ styles.append(r'\@namedef{%s@tok@%s}{%s}' % (cp, name, definition))
return STYLE_TEMPLATE % {'cp': self.commandprefix,
'styles': '\n'.join(styles)}