From ac0e4cb48365c0e2e5353bcacddf9d15a58ad851 Mon Sep 17 00:00:00 2001
From: facelessuser
Date: Mon, 5 Oct 2026 08:17:17 -0600
Subject: [PATCH] Ensure that unterminated HTML tags do not cause text to be
dropped
Ensure we handle both `` and `` in the attribute (#1647).
+* Fix issue where an unterminated end tag (` int: # pragma: no cover
# Treat `>` as normal data as it is not a real tag.
diff --git a/tests/test_syntax/blocks/test_html_blocks.py b/tests/test_syntax/blocks/test_html_blocks.py
index ecc10f45..1f2f8773 100644
--- a/tests/test_syntax/blocks/test_html_blocks.py
+++ b/tests/test_syntax/blocks/test_html_blocks.py
@@ -1787,3 +1787,60 @@ def test_unclosed_endtag(self):
'''
)
)
+
+ def test_unterminated_endtag_in_code_span(self):
+ """Ensure an unterminated end tag does not swallow the remaining content."""
+
+ # https://github.com/Python-Markdown/markdown/issues/1651
+ self.assertMarkdownRenders(
+ 'Run `cmd 2Run cmd 2</dev/null here.
+ This paragraph should not disappear.
+ '''
+ )
+ )
+
+ def test_additional_tail_cases(self):
+ """Ensure various tail cases survive."""
+
+ # https://github.com/Python-Markdown/markdown/issues/1651
+ self.assertMarkdownRenders(
+ self.dedent(
+ """
+ ` q
+
+ ` q
+
+ ` q
+
+ `` z
+ """
+ ),
+ self.dedent(
+ """
+ </dev z > q
+ </ab c z
+ </dev/ > q
+ </dev/null z > q
+ </ab c> z
+ """
+ )
+ )
+
+ def test_unterminated_endtag(self):
+ """Ensure an unterminated end tag is treated as text."""
+
+ # https://github.com/Python-Markdown/markdown/issues/1651
+ self.assertMarkdownRenders(
+ 'foo foo </bar
+ baz
+ '''
+ )
+ )