Translate line blocks with \raggedright.

This commit is contained in:
Georg Brandl 2008-06-17 09:26:50 +00:00
parent 309377fbbf
commit 9fce370623
2 changed files with 13 additions and 4 deletions

View File

@ -100,6 +100,9 @@ Bugs fixed
* Enable autodoc to process Unicode docstrings.
* The LaTeX writer now translates line blocks with ``\raggedright``,
which plays nicer with tables.
Release 0.3 (May 6, 2008)
=========================

View File

@ -865,16 +865,22 @@ class LaTeXTranslator(nodes.NodeVisitor):
* inline markup is supported.
* serif typeface
"""
self.body.append('\\begin{flushleft}\n')
self.body.append('{\\raggedright{}')
self.literal_whitespace = 1
def depart_line_block(self, node):
self.literal_whitespace = 0
self.body.append('\n\\end{flushleft}\n')
# remove the last \\
del self.body[-1]
self.body.append('}\n')
def visit_line(self, node):
pass
self._line_start = len(self.body)
def depart_line(self, node):
self.body.append('~\\\\\n')
if self._line_start == len(self.body):
# no output in this line -- add a nonbreaking space, else the
# \\ command will give an error
self.body.append('~')
self.body.append('\\\\\n')
def visit_block_quote(self, node):
# If the block quote contains a single object and that object