* Support \classdescni.

* Generate valid highlighting code even if code doesn't end in \n.
This commit is contained in:
Georg Brandl 2008-03-19 08:00:25 +00:00
parent 7b298368d3
commit c0a44f7996
2 changed files with 13 additions and 3 deletions

View File

@ -656,9 +656,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
hlcode = self.highlighter.highlight_block(code, lang, linenos)
# workaround for Unicode issue
hlcode = hlcode.replace(u'', u'@texteuro[]')
# workaround for Pygments bug
hlcode = hlcode.replace('\n\\end{Verbatim}', '\\end{Verbatim}')
self.body.append('\n' + hlcode)
# get consistent trailer
hlcode = hlcode.rstrip()[:-14] # strip \end{Verbatim}
hlcode = hlcode.rstrip() + '\n'
self.body.append('\n' + hlcode + '\\end{Verbatim}\n')
self.verbatim = None
visit_doctest_block = visit_literal_block
depart_doctest_block = depart_literal_block

View File

@ -685,6 +685,15 @@
\classline{#1}{#2}
}{\end{fulllineitems}}
\newcommand{\classlineni}[2]{
\py@sigline{\strong{class }\bfcode{#1}}{#2}}
\newenvironment{classdescni}[2]{
% Using \renewcommand doesn't work for this, for unknown reasons:
\global\def\py@thisclass{#1}
\begin{fulllineitems}
\classlineni{#1}{#2}
}{\end{fulllineitems}}
% \begin{classdesc*}{name}
\newenvironment{classdesc*}[1]{
% Using \renewcommand doesn't work for this, for unknown reasons: