Skip to content

Commit f3a68fa

Browse files
committed
Merge pull request #432 from facelessuser/master
Fix infinite loop #430
2 parents d442f57 + 6cd3765 commit f3a68fa

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

markdown/preprocessors.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,11 @@ def _nested_markdown_in_html(self, items):
178178
else: # raw html
179179
if len(items) - right_listindex <= 1: # last element
180180
right_listindex -= 1
181-
offset = 1 if i == right_listindex else 0
181+
if right_listindex <= i:
182+
right_listindex = i + 1
182183
placeholder = self.markdown.htmlStash.store('\n\n'.join(
183-
items[i:right_listindex + offset]))
184-
del items[i:right_listindex + offset]
184+
items[i:right_listindex]))
185+
del items[i:right_listindex]
185186
items.insert(i, placeholder)
186187
return items
187188

tests/extensions/extra/raw-html.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,9 @@
4141

4242
<p>Markdown is <em>still</em> active here.</p>
4343
</div>
44-
<p>Markdown is <em>active again</em> here.</p>
44+
<p>Markdown is <em>active again</em> here.</p>
45+
<div>
46+
<p>foo bar</p>
47+
<p><em>bar</em>
48+
</p>
49+
</div>

tests/extensions/extra/raw-html.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,9 @@ Markdown is *still* active here.
6565
</div>
6666

6767
Markdown is *active again* here.
68+
69+
<div markdown=1>
70+
foo bar
71+
72+
<em>bar</em>
73+
</div>

0 commit comments

Comments
 (0)