Skip to content

Commit dbddf88

Browse files
committed
Ensure we capture continued tail cases
1 parent a5cef11 commit dbddf88

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

markdown/extensions/md_in_html.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,7 @@ def handle_data(self, data):
265265
if self.inraw or not self.mdstack:
266266
super().handle_data(data)
267267
else:
268-
for i in range(len(self.mdstarted)):
269-
self.mdstarted[i] = False
268+
self.mdstarted[-1] = False
270269
self.treebuilder.data(data)
271270

272271
def handle_empty_tag(self, data, is_block):

tests/test_syntax/extensions/test_md_in_html.py

+42
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,48 @@ def test_md1_oneliner_block_mixed(self):
13141314
extensions=['md_in_html']
13151315
)
13161316

1317+
def test_md1_oneliner_block_tail(self):
1318+
# https://github.com/Python-Markdown/markdown/issues/1074
1319+
self.assertMarkdownRenders(
1320+
self.dedent(
1321+
"""
1322+
<div class="a" markdown="block"><div class="b" markdown="block">
1323+
**foo**
1324+
</div><div class="c" markdown="block"><div class="d" markdown="block">
1325+
*bar*
1326+
</div></div></div>
1327+
"""
1328+
),
1329+
'<div class="a">\n'
1330+
'<div class="b">\n'
1331+
'<p><strong>foo</strong></p>\n'
1332+
'</div>\n'
1333+
'<div class="c">\n'
1334+
'<div class="d">\n'
1335+
'<p><em>bar</em></p>\n'
1336+
'</div>\n'
1337+
'</div>\n'
1338+
'</div>',
1339+
extensions=['md_in_html']
1340+
)
1341+
1342+
def test_md1_oneliner_block_complex_start_tail(self):
1343+
# https://github.com/Python-Markdown/markdown/issues/1074
1344+
self.assertMarkdownRenders(
1345+
'<div class="a" markdown><div class="b" markdown>**foo**</div>'
1346+
'<div class="c" markdown>*bar*</div><div class="d">*not md*</div></div>',
1347+
'<div class="a">\n'
1348+
'<div class="b">\n'
1349+
'<p><strong>foo</strong></p>\n'
1350+
'</div>\n'
1351+
'<div class="c">\n'
1352+
'<p><em>bar</em></p>\n'
1353+
'</div>\n'
1354+
'<div class="d">*not md*</div>\n'
1355+
'</div>',
1356+
extensions=['md_in_html']
1357+
)
1358+
13171359
def test_md1_oneliner_block_start(self):
13181360
# https://github.com/Python-Markdown/markdown/issues/1074
13191361
self.assertMarkdownRenders(

0 commit comments

Comments
 (0)