Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [pull #559] Allow cuddled tables (#557)
- [pull #560] Fix `markdown-in-html` not always splitting HTML tags into separate lines (#558)
- [pull #564] Fix incomplete comments in safe mode not being escaped (#563)
- [pull #566] Fix crash in `markdown-in-html` extra (#565)


## python-markdown2 2.4.12
Expand Down
6 changes: 3 additions & 3 deletions lib/markdown2.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ def _hash_html_block_sub(self, match, raw=False):
except IndexError:
tag = None

tag = tag or re.match(r'^<(\S).*?>', html).group(1)
tag = tag or re.match(r'.*?<(\S).*?>', html).group(1)

if raw and self.safe_mode:
html = self._sanitize_html(html)
Expand All @@ -801,9 +801,9 @@ def _hash_html_block_sub(self, match, raw=False):
if m:
lines = html.split('\n')
# if MD is on same line as opening tag then split across two lines
lines = list(filter(None, (re.split(r'(<%s.*markdown=.*?>)' % tag, lines[0])))) + lines[1:]
lines = list(filter(None, (re.split(r'(.*?<%s.*markdown=.*?>)' % tag, lines[0])))) + lines[1:]
# if MD on same line as closing tag, split across two lines
lines = lines[:-1] + list(filter(None, re.split(r'(</%s>.*?$)' % tag, lines[-1])))
lines = lines[:-1] + list(filter(None, re.split(r'(\s*?</%s>.*?$)' % tag, lines[-1])))
# extract key sections of the match
first_line = lines[0]
middle = '\n'.join(lines[1:-1])
Expand Down
16 changes: 16 additions & 0 deletions test/tm-cases/markdown_in_html_in_lists.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,20 @@ <h6>Block three</h6>

</div></li>
</ul></li>


<li><p>one two</p>

<p>

<p><em>NOTE:</em> opening tag is slightly indented</p>

</p></li>
<li><p>three four</p>

<p>

<p><em>NOTE:</em> both tags are slightly indented</p>

</p></li>
</ul>
11 changes: 11 additions & 0 deletions test/tm-cases/markdown_in_html_in_lists.text
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,14 @@
###### Block three
Some text
</div>



- one two
<p markdown="1">
*NOTE:* opening tag is slightly indented
</p>
- three four
<p markdown="1">
*NOTE:* both tags are slightly indented
</p>