Skip to content

Commit 4d6b5e6

Browse files
authored
Fix issue with empty raw blocks (#2587)
1 parent 120dbc7 commit 4d6b5e6

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

docs/src/markdown/about/changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 10.14.3
4+
5+
- **FIX**: Blocks: An empty, raw block type should not cause an error.
6+
37
## 10.14.2
48

59
- **FIX**: Blocks: Fix some corner cases with `md_in_html`.

pymdownx/__meta__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,5 +185,5 @@ def parse_version(ver, pre=False):
185185
return Version(major, minor, micro, release, pre, post, dev)
186186

187187

188-
__version_info__ = Version(10, 14, 2, "final")
188+
__version_info__ = Version(10, 14, 3, "final")
189189
__version__ = __version_info__._get_canonical()

pymdownx/blocks/block.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,8 @@ def _end(self, block):
357357
mode = self.on_markdown()
358358
add = self.on_add(block)
359359
if mode == 'raw' or (mode == 'auto' and self.is_raw(add)):
360-
add.text = mutil.AtomicString(self.dedent(add.text))
360+
text = add.text if add.text is not None else ''
361+
add.text = mutil.AtomicString(self.dedent(text))
361362

362363
self.on_end(block)
363364

tests/test_extensions/test_blocks/test_html.py

+16
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@ class TestBlocksHTML(util.MdCase):
1414
}
1515
}
1616

17+
18+
def test_raw_empty_block(self):
19+
"""Test that raw empty blocks are handled properly."""
20+
21+
self.check_markdown(
22+
R'''
23+
/// html | pre
24+
///
25+
''',
26+
R'''
27+
<pre></pre>
28+
''',
29+
True
30+
)
31+
32+
1733
def test_bad_tag(self):
1834
"""Test bad HTML tag."""
1935

0 commit comments

Comments
 (0)