diff --git a/lib/markdown2.py b/lib/markdown2.py index 28cf4f40..41e408d0 100755 --- a/lib/markdown2.py +++ b/lib/markdown2.py @@ -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) @@ -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>.*?$)' % tag, lines[-1]))) # extract key sections of the match first_line = lines[0] middle = '\n'.join(lines[1:-1]) diff --git a/test/tm-cases/markdown_in_html_in_lists.html b/test/tm-cases/markdown_in_html_in_lists.html index 981113f9..18ae6bf3 100644 --- a/test/tm-cases/markdown_in_html_in_lists.html +++ b/test/tm-cases/markdown_in_html_in_lists.html @@ -34,4 +34,20 @@
one two
+ ++ +
NOTE: opening tag is slightly indented
+ +three four
+ ++ +
NOTE: both tags are slightly indented
+ ++ *NOTE:* opening tag is slightly indented +
+- three four ++ *NOTE:* both tags are slightly indented +