Skip to content

Commit

Permalink
confused about loose sublists
Browse files Browse the repository at this point in the history
  • Loading branch information
Mi Yu committed May 12, 2018
1 parent b5768ba commit ce34396
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion mistletoe/block_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,10 @@ def read(cls, lines):
line = next(lines)
line = line[prepend:] if newline else line.lstrip(' ')
line_buffer.append(line)
newline = next_line == '\n'
newline = next_line.strip() == ''
next_line = lines.peek()
if line_buffer[-1] == '\n':
line_buffer.pop()
return line_buffer, prepend, leader


Expand Down
9 changes: 5 additions & 4 deletions mistletoe/html_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, *extras):
extras (list): allows subclasses to add even more custom tokens.
"""
tokens = self._tokens_from_module(html_token)
self._suppress_ptag = False
self._suppress_ptag_stack = [False]
super().__init__(*chain(tokens, extras))

def render_strong(self, token):
Expand Down Expand Up @@ -95,7 +95,7 @@ def render_quote(self, token):
return template.format(inner=self.render_inner(token))

def render_paragraph(self, token):
if self._suppress_ptag:
if self._suppress_ptag_stack[-1]:
return '{}\n'.format(self.render_inner(token))
return '<p>{}</p>\n'.format(self.render_inner(token))

Expand All @@ -117,9 +117,10 @@ def render_list(self, token):
tag = 'ul'
attr = ''
if not token.loose:
self._suppress_ptag = True
self._suppress_ptag_stack.append(True)
inner = self.render_inner(token)
self._suppress_ptag = False
if not token.loose:
self._suppress_ptag_stack.pop()
return template.format(tag=tag, attr=attr, inner=inner)

def render_list_item(self, token):
Expand Down

0 comments on commit ce34396

Please sign in to comment.