Skip to content

Commit

Permalink
Adjust some white space formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
facelessuser committed Jan 25, 2025
1 parent df26e89 commit 7759343
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions markdown/extensions/md_in_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,15 @@ def handle_endtag(self, tag):

# Add a newline to tail if it is not just a trailing newline
if tail != '\n':
tail = '\n' + tail
tail = '\n' + tail.rstrip('\n')

# Ensure there is an empty new line between blocks
if not text.endswith('\n\n'):
text = text.rstrip('\n') + '\n\n'

# Process the block nested under the span appropriately
if state in ('span', 'block'):
current.text = f'{text}\n{self.md.htmlStash.store(child)}{tail}'
current.text = f'{text}{self.md.htmlStash.store(child)}{tail}'
last.append(child)
else:
# Non-Markdown HTML will not be recursively parsed for Markdown,
Expand All @@ -194,7 +198,7 @@ def handle_endtag(self, tag):
# processing.
child.attrib.pop('markdown')
[c.attrib.pop('markdown', None) for c in child.iter()]
current.text = f'{text}\n{self.md.htmlStash.store(child)}{tail}'
current.text = f'{text}{self.md.htmlStash.store(child)}{tail}'
# Target the child elements that have been expanded.
current = last.pop(0) if last else None

Expand Down

0 comments on commit 7759343

Please sign in to comment.