Repository navigation
Don't apply strike inside inline HTML tags - #786
Open
alphaNumericEntity wants to merge 2 commits into
Open
alphaNumericEntity wants to merge 2 commits into
alphaNumericEntity wants to merge 2 commits into
Conversation
The strike extra ran over the whole span text, so ~~ in tag attributes, link and image titles and inline HTML comments was turned into <s> tags, breaking the markup (e.g. <img src="a~~b~~c.png"> became src="a<s>b</s>c.png"). Swap tags and comments out for placeholders while the substitution runs, as the smarty-pants extra does.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
With the
strikeextra on, the~~substitution ran over the whole span text, inline HTML tags included.~~inside an attribute value was turned into<s>tags and broke the tag:Expected:
<p><img src="/img/a~~b~~c.png" alt="~~Alt~~"></p>The same happened to Markdown link and image titles (
[a](https://example.com/ "~~T~~")gavetitle="<s>T</s>") and to inline HTML comments (<!-- ~~x~~ -->gave<!-- <s>x</s> -->). A~~in an attribute could also pair with a~~in the text after the tag, so the<s>started inside the attribute:<img src="x.png" alt="a ~~">~~b~~gave<img src="x.png" alt="a <s>"></s>b~~.Emphasis doesn't have this problem because
_escape_special_charshides*and_inside tags, but~isn't in the escape table.Fix:
Strike.runnow swaps inline tags and comments for hash placeholders using the existing_sorta_html_tokenize_re, runs the substitution, then puts the tags back in a singlere.subpass, so a paragraph with many tags stays linear. This is the same approach thesmarty-pantsextra uses since #735. The placeholders aren't whitespace, so~~next to a tag (~~<b>x</b>~~) and strikes that span a tag (~~a <b>c</b> d~~) work as before.Not changed: the text of an auto-link like
<http://x.com/~~a~~>is still struck. By the time the extra runs it is an ordinary<a>element, and its text can't be told apart from link text such as[~~a~~](url), which should be struck.Tests:
tm-cases/strike_html_attributescovers a raw<img>with~~insrcandalt, a<span title>, Markdown link and image titles, an inline comment, and a strike around a tag. It fails without the fix.make testone: 311 tests OK with.[all]installed (310 on master).make testredos: 12 tests OK.strikeon (alone, and withfootnotes,tables+fenced-code-blocks,smarty-pants,markdown-in-html+header-ids+toc+task_list) and eachsafe_mode, on the test files plus inputs with strikes around and next to tags, code spans, escaped\~~, and links. Outputs only changed inside tags and comments.pycodestyle lib/markdown2.py: same warning count as master.The CHANGES.md entry is
[pull #786].