Skip to content

Commit

Permalink
Fix issue with empty raw blocks (#2587)
Browse files Browse the repository at this point in the history
  • Loading branch information
facelessuser authored Feb 1, 2025
1 parent 120dbc7 commit 4d6b5e6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/src/markdown/about/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 10.14.3

- **FIX**: Blocks: An empty, raw block type should not cause an error.

## 10.14.2

- **FIX**: Blocks: Fix some corner cases with `md_in_html`.
Expand Down
2 changes: 1 addition & 1 deletion pymdownx/__meta__.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,5 @@ def parse_version(ver, pre=False):
return Version(major, minor, micro, release, pre, post, dev)


__version_info__ = Version(10, 14, 2, "final")
__version_info__ = Version(10, 14, 3, "final")
__version__ = __version_info__._get_canonical()
3 changes: 2 additions & 1 deletion pymdownx/blocks/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,8 @@ def _end(self, block):
mode = self.on_markdown()
add = self.on_add(block)
if mode == 'raw' or (mode == 'auto' and self.is_raw(add)):
add.text = mutil.AtomicString(self.dedent(add.text))
text = add.text if add.text is not None else ''
add.text = mutil.AtomicString(self.dedent(text))

self.on_end(block)

Expand Down
16 changes: 16 additions & 0 deletions tests/test_extensions/test_blocks/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ class TestBlocksHTML(util.MdCase):
}
}


def test_raw_empty_block(self):
"""Test that raw empty blocks are handled properly."""

self.check_markdown(
R'''
/// html | pre
///
''',
R'''
<pre></pre>
''',
True
)


def test_bad_tag(self):
"""Test bad HTML tag."""

Expand Down

0 comments on commit 4d6b5e6

Please sign in to comment.