Skip to content

Commit 7759343

Browse files
committed
Adjust some white space formatting
1 parent df26e89 commit 7759343

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

markdown/extensions/md_in_html.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,15 @@ def handle_endtag(self, tag):
181181

182182
# Add a newline to tail if it is not just a trailing newline
183183
if tail != '\n':
184-
tail = '\n' + tail
184+
tail = '\n' + tail.rstrip('\n')
185+
186+
# Ensure there is an empty new line between blocks
187+
if not text.endswith('\n\n'):
188+
text = text.rstrip('\n') + '\n\n'
185189

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

0 commit comments

Comments
 (0)