Add nested OL test (for newlines) and correct lists nesting

This commit is contained in:
Rémi
2019-11-21 09:35:34 +01:00
parent 146104b41f
commit 7b788bafd4
2 changed files with 32 additions and 6 deletions

View File

@@ -151,14 +151,19 @@ class MarkdownConverter(object):
def convert_list(self, el, text):
nested = False
before_paragraph = False
print(el.name, repr(el.next_sibling), repr(text))
if el.next_sibling and el.next_sibling.name not in ['ul', 'ol']:
print(el.name, repr(el.next_sibling))
before_paragraph = True
while el:
if el.name == 'li':
nested = True
break
el = el.parent
if nested:
text = '\n' + self.indent(text, 1)
return '\n' + text + '\n'
text = '\n' + self.indent(text, 1).rstrip()
return text + ('\n' if before_paragraph else '')
convert_ul = convert_list
convert_ol = convert_list