Commits

Georg Brandl committed 7a34e47

#535: Fix LaTeX output generated for line blocks by porting implementation from new docutils code.

  • Participants
  • Parent commits 6bf5ee4

Comments (0)

Files changed (4)

+Release 1.0.5 (in development)
+==============================
+
+* #535: Fix LaTeX output generated for line blocks.
+
+* #544: Allow ``.pyw`` as a source file extension.
+
+
 Release 1.0.4 (Sep 17, 2010)
 ============================
 
-* #544: Allow ``.pyw`` as a source file extension.
-
 * #524: Open intersphinx inventories in binary mode on Windows,
   since version 2 contains zlib-compressed data.
 

sphinx/texinputs/sphinx.sty

 \RequirePackage{amsmath} % for \text
 \RequirePackage{makeidx}
 \RequirePackage{framed}
+\RequirePackage{ifthen}
 \RequirePackage{color}
 % For highlighted code.
 \RequirePackage{fancyvrb}
     {#2}% node content
   }% close "span"
 }
+
+\providecommand*{\DUprovidelength}[2]{
+  \ifthenelse{\isundefined{#1}}{\newlength{#1}\setlength{#1}{#2}}{}
+}
+
+\DUprovidelength{\DUlineblockindent}{2.5em}
+\ifthenelse{\isundefined{\DUlineblock}}{
+  \newenvironment{DUlineblock}[1]{%
+    \list{}{\setlength{\partopsep}{\parskip}
+            \addtolength{\partopsep}{\baselineskip}
+            \setlength{\topsep}{0pt}
+            \setlength{\itemsep}{0.15\baselineskip}
+            \setlength{\parsep}{0pt}
+            \setlength{\leftmargin}{#1}}
+    \raggedright
+  }
+  {\endlist}
+}{}

sphinx/writers/latex.py

     visit_doctest_block = visit_literal_block
     depart_doctest_block = depart_literal_block
 
+    def visit_line(self, node):
+        self.body.append('\item[] ')
+    def depart_line(self, node):
+        self.body.append('\n')
+
     def visit_line_block(self, node):
-        """line-block:
-        * whitespace (including linebreaks) is significant
-        * inline markup is supported.
-        * serif typeface
-        """
-        self.body.append('\n{\\raggedright{}')
-        self.literal_whitespace += 1
+        if isinstance(node.parent, nodes.line_block):
+            self.body.append('\\item[]\n'
+                             '\\begin{DUlineblock}{\\DUlineblockindent}\n')
+        else:
+            self.body.append('\n\\begin{DUlineblock}{0em}\n')
     def depart_line_block(self, node):
-        self.literal_whitespace -= 1
-        # remove the last \\
-        del self.body[-1]
-        self.body.append('}\n')
-
-    def visit_line(self, node):
-        self._line_start = len(self.body)
-    def depart_line(self, node):
-        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('~')
-        if self.table is not None:
-            self.body.append('\\newline\n')
-        else:
-            self.body.append('\\\\\n')
+        self.body.append('\\end{DUlineblock}\n')
 
     def visit_block_quote(self, node):
         # If the block quote contains a single object and that object

tests/root/markup.txt

 -h              help
 --help          also help
 
+Line block:
+
+| line1
+|   line2
+|     line3
+|       line4
+|   line5
+| line6
+|   line7
+
 
 Body directives
 ^^^^^^^^^^^^^^^