Skip to content

Commit

Permalink
Fix remaining tests
Browse files Browse the repository at this point in the history
  • Loading branch information
facelessuser committed Oct 15, 2020
1 parent dcada15 commit 0827498
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions markdown/extensions/md_in_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ def get_state(self, tag, attrs):
else: # pragma: no cover
return None

def at_line_start(self):
"""At line start."""

value = super().at_line_start()
if not value and self.cleandoc and self.cleandoc[-1] == '\n\n':
value = True
return value

def handle_starttag(self, tag, attrs):
if tag in block_level_tags:
# Valueless attr (ex: `<tag checked>`) results in `[('checked', None)]`.
Expand Down Expand Up @@ -128,6 +136,14 @@ def handle_endtag(self, tag):
if not self.mdstack:
# Last item in stack is closed. Stash it
element = self.get_element()
# Get last entry to see if it ends in newlines
# If it is an element, assume there is no newlines
item = self.cleandoc[-1] if self.cleandoc else ''
if not isinstance(item, str):
item = ''
# If we only have one newline before block element, add another
if not item.endswith('\n\n') and item.endswith('\n'):
self.cleandoc.append('\n')
self.cleandoc.append(self.md.htmlStash.store(element))
self.cleandoc.append('\n\n')
self.state = []
Expand Down

0 comments on commit 0827498

Please sign in to comment.