-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
First stab at functional $inside
#4032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v2
Are you sure you want to change the base?
Conversation
c7f907f to
3eb1e71
Compare
src/core/tokenize/match.js
Outdated
| !grammar.hasOwnProperty(token) || | ||
| token.startsWith('$') || | ||
| !tokenValue || | ||
| typeof tokenValue === 'function' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functional tokens ($inside for now) are handled on L170, and we should ignore them in all other cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, it should. I'll add it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
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
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