Repository navigation
Conversation
|
@kevin9327 is attempting to deploy a commit to the MarkedJS Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Marked version: 18.1.3 (master ba50aa9)
Markdown flavor: CommonMark|GitHub Flavored Markdown
Description
Emphasis never opens or closes inside angle brackets, even when the brackets are plain text:
Expectation
That is what commonmark.js and the CommonMark spec give:
<*name*>is neither raw HTML nor an autolink, so it is ordinary text and the*delimiters inside count.Result
Same for
<_one_>,<**two**>,*foo <bar* baz>and*<a*a>.The cause is the em/strong mask:
blockSkipmasks every<...>run that does not start with a space (<(?! )[^<>]*?>), so emStrong never sees the delimiters in it, whether or not the run is a tag. The same shortcut cuts a real tag short at the first>: in*a <b title=">*">*the*inside the quoted attribute was left unmasked and closed the emphasis, which split the tag and rendered it as escaped text (<em>a <b title="></em>">*).Fix
#maskSrcnow masks blocks with a small loop (#maskBlocks). Links and code spans are masked exactly as before. For a<...>match it runs the existing inlinetagandautolinkrules at that position: when one matches, the whole tag or autolink is masked (also past the first>); otherwise the text stays unmasked and the scan resumes after the<.rules.tsis unchanged, soblockSkip(also used bylinkInText) keeps its current regex and recheck result. The loop only adds an anchoredtag/autolinkattempt at positions where the inline tokenizer already tries the same rules.Tests
test/specs/new/em_in_angle_brackets.{md,html}covering plain-text angle brackets (<*name*>,<_one_>,<**two**>,*foo <bar* baz>) and real HTML/autolinks that must stay masked (<b x="*">,<b title=">*">,<http://x.y/*z>,<!-- * -->). The expected HTML matches commonmark.js output for the same input.npm run test:specs1983 pass / 2 fail (the new spec). After: 1985 pass / 0 fail.npm run test:unit242 pass.eslintandtsc --noEmitclean; umd/cjs smoke tests pass.'<a>*'.repeat(30000),'<*a*> '.repeat(20000),'*<x '.repeat(30000)) stays in the same range as 18.1.3 (about 45-70 ms each on my machine).AI assistance: I used an AI coding assistant to help find this (differential fuzzing against commonmark.js), write the fix and tests; I reviewed the change and ran the test suites above.
Contributor
Committer
In most cases, this should be a different person than the contributor.