Don't escape underscores that can't close emphasis#582
Open
apoorva-01 wants to merge 1 commit into
Open
Conversation
Emphasis needs a closing delimiter, so escaping only the runs that can close keeps every underscore literal without the needless backslashes.
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.
Closes #557
Right now literal underscores that can't form emphasis still get escaped, so
*target=_blank*turns into*target=\_blank*andAs a ______,into a row of\_. Same HTML, just noisy.Fix: emphasis needs a closer, so only escape underscore runs that can close emphasis (per §6.2). If the closers stay escaped, the openers have nothing to pair with. Intraword and isolated
_were already fine.One catch: a
_-emphasis span wraps its content in literal_markers that can pair with a relaxed underscore in the same inline, so escaping stays conservative when an inline contains any_emphasis (the smallinlinerenderer handles that). I kept it to this local heuristic rather than full delimiter pairing, happy to go bigger if you'd prefer.Heads up it changes default output for everyone (like #464/#465), and
Do _escapein the fixtures now stays unescaped on purpose. Added spec-style tests, spec suite unchanged, fuzzed ~600k inputs for same-HTML,toxgreen.