Fix for issue #47.
This commit is contained in:
parent
52135c8142
commit
3e7b506f77
|
@ -198,24 +198,36 @@ class JSONTranslator(nodes.GenericNodeVisitor):
|
|||
self.lit_block = False
|
||||
|
||||
def visit_bullet_list(self, node):
|
||||
self.bullet_stack.append('*')
|
||||
if self.first_row > 0:
|
||||
self.text += """<ul>"""
|
||||
else:
|
||||
self.bullet_stack.append('*')
|
||||
|
||||
def depart_bullet_list(self, node):
|
||||
self.bullet_stack.pop()
|
||||
self.list_indent = len(self.bullet_stack) - 1
|
||||
if len(self.bullet_stack) is 0:
|
||||
self.text += '\n'
|
||||
if self.first_row > 0:
|
||||
self.text += """</ul>"""
|
||||
else:
|
||||
self.bullet_stack.pop()
|
||||
self.list_indent = len(self.bullet_stack) - 1
|
||||
if len(self.bullet_stack) is 0:
|
||||
self.text += '\n'
|
||||
|
||||
def visit_list_item(self, node):
|
||||
self.list_indent = len(self.bullet_stack) - 1
|
||||
item = '\n%s%s ' % (' ' * self.list_indent,
|
||||
self.bullet_stack[-1])
|
||||
self.text += item
|
||||
self.listitem = True
|
||||
if self.first_row > 0:
|
||||
self.text += """<li>"""
|
||||
else:
|
||||
self.list_indent = len(self.bullet_stack) - 1
|
||||
item = '\n%s%s ' % (' ' * self.list_indent,
|
||||
self.bullet_stack[-1])
|
||||
self.text += item
|
||||
self.listitem = True
|
||||
|
||||
def depart_list_item(self, node):
|
||||
self.listitem = False
|
||||
self.list_indent = 0
|
||||
if self.first_row > 0:
|
||||
self.text += """</li>"""
|
||||
else:
|
||||
self.listitem = False
|
||||
self.list_indent = 0
|
||||
|
||||
def visit_title(self, node):
|
||||
self.current_node_name = node.__class__.__name__
|
||||
|
|
|
@ -573,6 +573,51 @@ Example requests and responses:
|
|||
| End `text` | `Name` | Description | `start` text |
|
||||
|
||||
|
||||
'''
|
||||
|
||||
json = rest.publish_string(rst)
|
||||
assert json == {'paths':
|
||||
{'/path':
|
||||
[minimal_method_json(description=markdown)]},
|
||||
'tags': []}
|
||||
|
||||
def test_table_with_list(self):
|
||||
rst = """
|
||||
.. http:get:: /path
|
||||
|
||||
Some text before table
|
||||
|
||||
+------------------------+------------------------------------------+
|
||||
| Response code | Description |
|
||||
+------------------------+------------------------------------------+
|
||||
| ``Bad Request (400)`` | The Identity service failed to parse the |
|
||||
| | following errors occurred: |
|
||||
| | |
|
||||
| | - A required attribute was missing. |
|
||||
| | |
|
||||
| | - An attribute that is not allowed was a |
|
||||
| | POST request in a basic CRUD op. |
|
||||
| | |
|
||||
| | - An ``attribute`` of an unexpected data |
|
||||
+------------------------+------------------------------------------+
|
||||
| ``Forbidden (403)`` | The identity was successfully authent. |
|
||||
| | authorized to perform the action. |
|
||||
+------------------------+------------------------------------------+
|
||||
|
||||
"""
|
||||
|
||||
markdown = '''Some text before table
|
||||
|
||||
| Response code | Description |
|
||||
| --- | --- |
|
||||
| `Bad Request (400)` | The Identity service failed to parse the<br>following \
|
||||
errors occurred:<ul><li>A required attribute was missing.</li><li>An\
|
||||
attribute that is not allowed was a<br>POST request in a basic CRUD op.\
|
||||
</li><li>An `attribute` of an unexpected data</li></ul> |
|
||||
| `Forbidden (403)` | The identity was successfully authent.<br>authorized\
|
||||
to perform the action. |
|
||||
|
||||
|
||||
'''
|
||||
|
||||
json = rest.publish_string(rst)
|
||||
|
|
Loading…
Reference in New Issue