Skip to content

Fix hashing nested HTML blocks#483

Merged
nicholasserra merged 3 commits intotrentm:masterfrom
Crozzers:div-closing-tag-paragraph-issue481
Nov 2, 2022
Merged

Fix hashing nested HTML blocks#483
nicholasserra merged 3 commits intotrentm:masterfrom
Crozzers:div-closing-tag-paragraph-issue481

Conversation

@Crozzers
Copy link
Copy Markdown
Contributor

This PR fixes #481 by fixing _hash_html_blocks matching the wrong HTML closing tag when hashing HTML blocks.

An example like this:

<div class="enclosing">
<div class="codehilite">
<pre><span></span><code><span class="n">x</span> <span class="o">=</span> <span class="mi">1</span>
</code></pre>
</div>

</div>

Would end up with the final closing </div> tag wrapped in <p> tags as the _strict_block_tag_re failed to match against the whole <div> block correctly.

This fix solves this issue by iterating over the given text and manually tallying up the number of opening and closing <div> tags and then hashing the relevant block.

Nested HTML blocks of the same type (eg: nested div's) would be hashed incorrectly
as the `_strict_block_tag_re` would match the FIRST closing tag and ignore any subsequent
closing tags. This commit fixes this behaviour by iterating over all the lines in a
given text, manually tallying up the number of opening/closing tags and then hashing
the relevant block
@nicholasserra
Copy link
Copy Markdown
Collaborator

LGTM thanks!

@nicholasserra nicholasserra merged commit 499f733 into trentm:master Nov 2, 2022
@Crozzers Crozzers deleted the div-closing-tag-paragraph-issue481 branch November 4, 2022 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enclosing fenced-code-blocks in a <div> tag renders incorrect HTML

2 participants