Open
Conversation
c7f907f to
3eb1e71
Compare
DmitrySharabin
commented
Nov 24, 2025
src/core/tokenize/match.js
Outdated
| !grammar.hasOwnProperty(token) || | ||
| token.startsWith('$') || | ||
| !tokenValue || | ||
| typeof tokenValue === 'function' |
Member
Author
There was a problem hiding this comment.
Functional tokens ($inside for now) are handled on L170, and we should ignore them in all other cases.
Member
Author
There was a problem hiding this comment.
Right, it should. I'll add it
dd0af79 to
26bf9fb
Compare
83b27d5 to
b1856ff
Compare
b1856ff to
e143bcb
Compare
✅ Deploy Preview for dev-prismjs-com ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
e143bcb to
5eeb334
Compare
…objects The regex coverage test was failing to track pattern matches because Prism creates new `RegExp objects` when adding flags (e.g., `g` or `d`) during tokenization. The original approach intercepted `exec()` on individual regex objects, which missed matches on the newly created `RegExp` instances. Changes: - Replace `String(regex)` key with normalized source+flags key to match patterns even when Prism creates new `RegExp` objects with different flags - Switch from per-regex interception to global `RegExp.prototype.exec` interception to catch all pattern matches, including on new `RegExp` objects - Use a simple loop instead of `String.replace` in flag normalization to avoid triggering our own `RegExp.exec` interception (which caused infinite loops) This fixes the tracking issue for patterns like the markdown code block pattern that were previously reported as untested despite being used in tests.
Plus, add tests.
5eeb334 to
2fe2161
Compare
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.
The code from the
simplifybranch, authored mainly by @LeaVerou.Summary
tokenizeByNamedGroups()andcamelToKebabCase()utilsresolve()now accepts functional tokens_matchGrammar()to not choke on functional tokensWith #4018 and #4029 merged, the changes in this PR don't break any tests; all of them still pass.
This is part 2 of 2 in a stack made with GitButler:
$inside#4032 👈simplifybranch) #4029