Fix safemode regressions (#660) #663
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes #660. Mostly a number of safemode regressions and edgecases not quite fixed in #659.
First change is I've tweaked
_hash_html_spansto avoid processing raw markdown code spans, as they can often be made to look like they contain HTML. It does this by hashing those segments and ignoring them. The code is then processed as normal and encoded later on in the process.Second, I fixed escaped tags not being processed correctly by checking for any escapes and consuming them in
_encode_incomplete_tags.Finally, code spans with a lexer attached were getting joined to lists above them. An attempted fix was made in #659 by playing around with adding/removing newlines after the code block.
This change fixes that by just checking for user inserted newlines surrounding the code block in the markdown and preserving those, rather than playing guessing games with what we think will work.