Skip to content

Commit

Permalink
More consistent newline handling in blocks extensions (#2553)
Browse files Browse the repository at this point in the history
  • Loading branch information
facelessuser authored Dec 23, 2024
1 parent 9e26f64 commit 271950f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/src/markdown/about/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- **FIX**: Snippets: Properly capture empty newline at end of file.
- **FIX**: Snippets: Fix issue where when non sections of files are included, section labels are not stripped.
- **FIX**: BetterEm: Fixes for complex cases.
- **FIX**: Blocks: More consistent handling of empty newlines in block processor extensions.

## 10.12

Expand Down
4 changes: 2 additions & 2 deletions pymdownx/blocks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,10 @@ def parse_blocks(self, blocks, entry):
if is_atomic or not is_block:
child = list(target)[-1] if len(target) else None
text = target.text if child is None else child.tail
b = '\n\n'.join(unescape_markdown(self.md, [b], is_atomic))
b = '\n\n'.join(unescape_markdown(self.md, [b], is_atomic)).strip('\n')

if text:
text += '\n\n' + b
text += b if not b else '\n\n' + b
else:
text = b

Expand Down
2 changes: 1 addition & 1 deletion pymdownx/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def parse_snippets(self, lines, file_name=None, is_url=False, is_section=False):
st = int(span[0]) if span[0] else None
start.append(st if st is None or st < 0 else max(0, st - 1))
en = int(span[1]) if len(span) > 1 and span[1] else None
end.append(en if en is None or en >= 0 else en)
end.append(en)
elif m.group(3):
section = m.group(3)[1:]

Expand Down
2 changes: 0 additions & 2 deletions tests/test_extensions/test_blocks/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,6 @@ def test_inline_and_md_in_html(self):
**content**
</div>
<strong>content</strong></div>
''',
True
Expand Down

0 comments on commit 271950f

Please sign in to comment.