diff options
-rw-r--r-- | markdown/preprocessors.py | 8 | ||||
-rw-r--r-- | tests/misc/html.html | 11 | ||||
-rw-r--r-- | tests/misc/html.txt | 11 |
3 files changed, 29 insertions, 1 deletions
diff --git a/markdown/preprocessors.py b/markdown/preprocessors.py index 7ea4fcf..94f9830 100644 --- a/markdown/preprocessors.py +++ b/markdown/preprocessors.py @@ -258,7 +258,13 @@ class HtmlBlockPreprocessor(Preprocessor): else: items.append(block) - right_tag, data_index = self._get_right_tag(left_tag, 0, block) + # Need to evaluate all items so we can calculate relative to the left index. + right_tag, data_index = self._get_right_tag(left_tag, left_index, ''.join(items)) + # Adjust data_index: relative to items -> relative to last block + prev_block_length = 0 + for item in items[:-1]: + prev_block_length += len(item) + data_index -= prev_block_length if self._equal_tags(left_tag, right_tag): # if find closing tag diff --git a/tests/misc/html.html b/tests/misc/html.html index 1eb6a97..5380bbd 100644 --- a/tests/misc/html.html +++ b/tests/misc/html.html @@ -8,6 +8,17 @@ Html with various attributes. </div> +<div> + <div> + Div with a blank line + + in the middle. + </div> + <div> + This gets treated as HTML. + </div> +</div> + <p>And of course <script>blah</script>.</p> <p><a href="script>stuff</script">this <script>link</a></p> <p>Some funky <x\]> inline stuff with markdown escaping syntax.</p> diff --git a/tests/misc/html.txt b/tests/misc/html.txt index dfee68d..8f18fa7 100644 --- a/tests/misc/html.txt +++ b/tests/misc/html.txt @@ -11,6 +11,17 @@ Now some <arbitrary>arbitrary tags</arbitrary>. Html with various attributes. </div> +<div> + <div> + Div with a blank line + + in the middle. + </div> + <div> + This gets treated as HTML. + </div> +</div> + And of course <script>blah</script>. [this <script>link](<script>stuff</script>) |