Skip to content

Commit 271950f

Browse files
authored
More consistent newline handling in blocks extensions (#2553)
1 parent 9e26f64 commit 271950f

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

docs/src/markdown/about/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- **FIX**: Snippets: Properly capture empty newline at end of file.
99
- **FIX**: Snippets: Fix issue where when non sections of files are included, section labels are not stripped.
1010
- **FIX**: BetterEm: Fixes for complex cases.
11+
- **FIX**: Blocks: More consistent handling of empty newlines in block processor extensions.
1112

1213
## 10.12
1314

pymdownx/blocks/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,10 @@ def parse_blocks(self, blocks, entry):
372372
if is_atomic or not is_block:
373373
child = list(target)[-1] if len(target) else None
374374
text = target.text if child is None else child.tail
375-
b = '\n\n'.join(unescape_markdown(self.md, [b], is_atomic))
375+
b = '\n\n'.join(unescape_markdown(self.md, [b], is_atomic)).strip('\n')
376376

377377
if text:
378-
text += '\n\n' + b
378+
text += b if not b else '\n\n' + b
379379
else:
380380
text = b
381381

pymdownx/snippets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def parse_snippets(self, lines, file_name=None, is_url=False, is_section=False):
321321
st = int(span[0]) if span[0] else None
322322
start.append(st if st is None or st < 0 else max(0, st - 1))
323323
en = int(span[1]) if len(span) > 1 and span[1] else None
324-
end.append(en if en is None or en >= 0 else en)
324+
end.append(en)
325325
elif m.group(3):
326326
section = m.group(3)[1:]
327327

tests/test_extensions/test_blocks/test_html.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,6 @@ def test_inline_and_md_in_html(self):
251251
**content**
252252
</div>
253253
254-
255-
256254
<strong>content</strong></div>
257255
''',
258256
True

0 commit comments

Comments
 (0)