diff options
author | Jonathan Protzenko <jonathan.protzenko@gmail.com> | 2013-09-04 21:58:05 +0200 |
---|---|---|
committer | Jonathan Protzenko <jonathan.protzenko@gmail.com> | 2013-09-04 21:58:05 +0200 |
commit | 342f9b5f2720ab257cea0ca934f1c82d9cbfab72 (patch) | |
tree | 35c791cc5bddb8474b9087b96a689d8230bbcc5e | |
parent | 1ea0fa53d253eae501f0a48611dd01493240b34d (diff) | |
download | pygments-342f9b5f2720ab257cea0ca934f1c82d9cbfab72.tar.gz |
Add a new envname option to the latex formatter.
It allows the user to pick a different environment name, for instance, BVerbatim
instead of the now-default Verbatim.
-rw-r--r-- | pygments/formatters/latex.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/pygments/formatters/latex.py b/pygments/formatters/latex.py index 47fd1239..60b71594 100644 --- a/pygments/formatters/latex.py +++ b/pygments/formatters/latex.py @@ -218,6 +218,11 @@ class LatexFormatter(Formatter): If set to ``True``, enables LaTeX math mode escape in comments. That is, ``'$...$'`` inside a comment will trigger math mode (default: ``False``). *New in Pygments 1.2.* + + `envname` + Allows you to pick an alternative environment name, such as BVerbatim. + (default: ``Verbatim''). *New in Pygments 1.6* + """ name = 'LaTeX' aliases = ['latex', 'tex'] @@ -235,6 +240,7 @@ class LatexFormatter(Formatter): self.commandprefix = options.get('commandprefix', 'PY') self.texcomments = get_bool_opt(options, 'texcomments', False) self.mathescape = get_bool_opt(options, 'mathescape', False) + self.envname = options.get('envname', 'Verbatim') self._create_stylesheet() @@ -306,7 +312,7 @@ class LatexFormatter(Formatter): realoutfile = outfile outfile = StringIO() - outfile.write(ur'\begin{Verbatim}[commandchars=\\\{\}') + outfile.write(ur'\begin{' + self.envname + ur'}[commandchars=\\\{\}') if self.linenos: start, step = self.linenostart, self.linenostep outfile.write(u',numbers=left' + @@ -366,7 +372,7 @@ class LatexFormatter(Formatter): else: outfile.write(value) - outfile.write(u'\\end{Verbatim}\n') + outfile.write(u'\\end{'+self.envname+u'}\n') if self.full: realoutfile.write(DOC_TEMPLATE % |