Commits

André Felipe Dias  committed f361ef8

fixes #15 | line blocks are broken

  • Participants
  • Parent commits 054a62e

Comments (0)

Files changed (3)

File rst2html5.py

         self.default_departure(node)
         self.context.begin_elem()  # next td
 
-    '''
-    Line blocks use <pre>. lines breaks and spacing are reconstructured
-    '''
 
     def visit_line(self, node):
-        if self.line_block_number:
+        self.line_level = getattr(self, 'line_level', -1) + 1
+        if self.line_level:
             tab_width = self.document.settings.tab_width
             separator = '\n' + ' ' * tab_width * (self.line_block_level - 1)
-        else:
-            separator = ''
-        self.context.append(separator, indent=False)
+            self.context.append(separator, indent=False)
+
         raise nodes.SkipDeparture
 
     def visit_line_block(self, node):
-        self.line_block_number = getattr(self, 'line_block_number', -1) + 1
+        '''
+        Line blocks use <pre>.
+        Lines breaks and spacing are reconstructured based on line_block_level
+        '''
         self.line_block_level = getattr(self, 'line_block_level', 0) + 1
         if self.line_block_level == 1:
             self.default_visit(node)
         self.line_block_level -= 1
         if self.line_block_level == 0:
             del self.line_block_level
+            del self.line_level
             self.default_departure(node)
 
     def visit_meta(self, node):
 
 setup(
     name='rst2html5',
-    version='1.0',
+    version='1.1',
     author='André Felipe Dias',
     author_email='andref.dias@gmail.com',
     url='https://bitbucket.org/andre_felipe_dias/rst2html5',

File tests/cases.py

     'part': 'body'
 }
 
+
+line_block_2 = {
+    'rst': '''Some text
+
+|      1234 Sesame St.
+|      New York, NY 10001
+|      tel:555-111-1111
+|      nobody@nowhere.org
+
+.. sidebar:: Contact
+
+   | 123 Address St.
+   | City, State ZIP
+''',
+    'part': 'body',
+    'out': '''
+    <p>Some text</p>
+    <pre class="line_block">1234 Sesame St.
+New York, NY 10001
+<a href="tel:555-111-1111">tel:555-111-1111</a>
+<a href="mailto:nobody@nowhere.org">nobody@nowhere.org</a></pre>
+    <aside class="sidebar">
+        <h1>Contact</h1>
+        <pre class="line_block">123 Address St.
+City, State ZIP</pre>
+    </aside>
+''',
+}
+
+line_block_3 = {
+    'rst': '''Take it away, Eric the Orchestra Leader!
+
+| A one, two, a one two three four
+|
+| Half a bee, philosophically,
+|     must, *ipso facto*, half not be.
+| But half the bee
+  has got to be,
+|     *vis a vis* its entity.  D'you see?
+|
+| But can a bee be said to be
+|     or not to be an entire bee,
+|         when half the bee is not a bee,
+|             due to some ancient injury?
+|
+| Singing...
+''',
+    'out': '''
+    <p>Take it away, Eric the Orchestra Leader!</p>
+    <pre class="line_block">A one, two, a one two three four
+
+Half a bee, philosophically,
+    must, <em>ipso facto</em>, half not be.
+But half the bee has got to be,
+    <em>vis a vis</em> its entity. D'you see?
+    
+But can a bee be said to be
+    or not to be an entire bee,
+        when half the bee is not a bee,
+            due to some ancient injury?
+            
+Singing...</pre>
+''',
+    'part': 'body',
+}
+
 legend = {
     'rst': '''.. figure:: picture.png
    :scale: 50%