From b36444cae72f02a16b8a8b3a98614eef2a046602 Mon Sep 17 00:00:00 2001 From: Crozzers Date: Wed, 11 Mar 2026 20:14:33 +0000 Subject: [PATCH 1/2] Fix #686 --- lib/markdown2.py | 2 +- test/tm-cases/hash_html_blocks_issue686.html | 3 +++ test/tm-cases/hash_html_blocks_issue686.tags | 1 + test/tm-cases/hash_html_blocks_issue686.text | 3 +++ 4 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 test/tm-cases/hash_html_blocks_issue686.html create mode 100644 test/tm-cases/hash_html_blocks_issue686.tags create mode 100644 test/tm-cases/hash_html_blocks_issue686.text diff --git a/lib/markdown2.py b/lib/markdown2.py index b831896f..14ae415c 100755 --- a/lib/markdown2.py +++ b/lib/markdown2.py @@ -922,7 +922,7 @@ def _hash_html_block_sub( tag = None if not tag: - m = re.match(r'.*?<(\S).*?\s*>', html) + m = re.match(r'.*?<(\S).*?\s*>', html, re.S) # tag shouldn't be none but make the assertion for type checker assert m is not None tag = m.group(1) diff --git a/test/tm-cases/hash_html_blocks_issue686.html b/test/tm-cases/hash_html_blocks_issue686.html new file mode 100644 index 00000000..a6398989 --- /dev/null +++ b/test/tm-cases/hash_html_blocks_issue686.html @@ -0,0 +1,3 @@ +

test +

diff --git a/test/tm-cases/hash_html_blocks_issue686.tags b/test/tm-cases/hash_html_blocks_issue686.tags new file mode 100644 index 00000000..7bd1a023 --- /dev/null +++ b/test/tm-cases/hash_html_blocks_issue686.tags @@ -0,0 +1 @@ +issue686 assertionerror \ No newline at end of file diff --git a/test/tm-cases/hash_html_blocks_issue686.text b/test/tm-cases/hash_html_blocks_issue686.text new file mode 100644 index 00000000..a6398989 --- /dev/null +++ b/test/tm-cases/hash_html_blocks_issue686.text @@ -0,0 +1,3 @@ +

test +

From a53a6116662f8022556760552b1166e2606c0bf6 Mon Sep 17 00:00:00 2001 From: Crozzers Date: Wed, 11 Mar 2026 20:16:48 +0000 Subject: [PATCH 2/2] Update changelog --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 707592c2..839d1a14 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,7 +2,7 @@ ## python-markdown2 2.5.6 (not yet released) -(nothing yet) +- [pull #687] Fix AssertionError hashing HTML blocks spread over multiple lines (#686) ## python-markdown2 2.5.5