-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: expose raw options on EmulatedRegExp
#15
Conversation
I'm fine with adding this if it's needed, but is it possible to avoid? The raw options are already available from // pseudo code
let jsCode = ''
for (const pattern of patterns) {
const d = toDetails(pattern, {
global: true,
// ...more options
})
jsCode += d.subclass ?
`new EmulatedRegExp(${JSON.stringify(d.pattern)}, '${d.flags}', ${JSON.stringify(d.subclass)})` :
// Avoid escaping already-escaped forward slashes
`/${d.pattern ? str.replace(/\\?./gsu, m => m === '/' ? '\\/' : m) : '(?:)'}/${d.flags}`
} This forces setting the Very open to any feedback, and like I said, I'm open to exposing this. That said, I don't think the current PR handles everything. I think you'd also need the raw/original pattern in order to cover all the edge cases, due to the underlying behavior from the |
https://github.com/shikijs/shiki/blob/2ac68cfbdd772466890fac1ddd9b77fe9b2c9bb5/packages/langs-precompiled/scripts/precompile.ts#L8-L14 As long as we get the logic work, I am fine with the API design. If you have an idea to improve it without changing the API, would you directly commit to the branch and see? Thanks |
Yes.
I suspect we could find a way to make it work without changing the I'll go ahead and merge this as a starting point, but I'll need to do a few follow up diffs (and maybe publish a new version of I'll let you know when it's ready! |
Along with other improvements, v0.10.0 also renamed |
I would need this for shikijs/shiki#878 where I can serialized it into JS code with like: