Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Classes | Functions | Variables
pip._vendor.pygments.formatters.latex Namespace Reference

Classes

class  LatexEmbeddedLexer
 
class  LatexFormatter
 

Functions

 escape_tex (text, commandprefix)
 
 _get_ttype_name (ttype)
 

Variables

str DOC_TEMPLATE
 
str STYLE_TEMPLATE
 Small explanation of the mess below :)
 

Detailed Description

    pygments.formatters.latex
    ~~~~~~~~~~~~~~~~~~~~~~~~~

    Formatter for LaTeX fancyvrb output.

    :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.

Variable Documentation

◆ DOC_TEMPLATE

str pip._vendor.pygments.formatters.latex.DOC_TEMPLATE
Initial value:
1= r'''
2\documentclass{%(docclass)s}
3\usepackage{fancyvrb}
4\usepackage{color}
5\usepackage[%(encoding)s]{inputenc}
6%(preamble)s
7
8%(styledefs)s
9
10\begin{document}
11
12\section*{%(title)s}
13
14%(code)s
15\end{document}
16'''

◆ STYLE_TEMPLATE

str pip._vendor.pygments.formatters.latex.STYLE_TEMPLATE

Small explanation of the mess below :)

The previous version of the LaTeX formatter just assigned a command to each token type defined in the current style. That obviously is problematic if the highlighted code is produced for a different style than the style commands themselves.

This version works much like the HTML formatter which assigns multiple CSS classes to each tag, from the most specific to the least specific token type, thus falling back to the parent token type if one is not defined. Here, the classes are there too and use the same short forms given in token.STANDARD_TYPES.

Highlighted code now only uses one custom command, which by default is \PY and selectable by the commandprefix option (and in addition the escapes \PYZat, \PYZlb and \PYZrb which haven't been renamed for backwards compatibility purposes).

\PY has two arguments: the classes, separated by +, and the text to render in that style. The classes are resolved into the respective style commands by magic, which serves to ignore unknown classes.

The magic macros are:

  • \PY@it, \PY@bf, etc. are unconditionally wrapped around the text to render in \PY@do. Their definition determines the style.
  • \PY@reset resets \PY@it etc. to do nothing.
  • \PY@toks parses the list of classes, using magic inspired by the keyval package (but modified to use plusses instead of commas because fancyvrb redefines commas inside its environments).
  • \PY@tok processes one class, calling the \PY@tok@classname command if it exists.
  • \PY@tok@classname sets the \PY@it etc. to reflect the chosen style for its class.
  • \PY resets the style, parses the classnames and then calls \PY@do.

Tip: to read this code, print it out in substituted form using e.g.

‍print STYLE_TEMPLATE % {'cp': 'PY'}