Skip to content

Fix HTML parse with empty lines #537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2017
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
8 changes: 7 additions & 1 deletion markdown/preprocessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,13 @@ def run(self, lines):
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
Expand Down
11 changes: 11 additions & 0 deletions tests/misc/html.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ <h1>Block level html</h1>
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&gt;stuff&lt;/script">this <script>link</a></p>
<p>Some funky <x\]> inline stuff with markdown escaping syntax.</p>
Expand Down
11 changes: 11 additions & 0 deletions tests/misc/html.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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>)
Expand Down