-
Notifications
You must be signed in to change notification settings - Fork 148
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
[wip] add settings-based code extractors #1080
base: main
Are you sure you want to change the base?
[wip] add settings-based code extractors #1080
Conversation
👈 Launch a binder notebook on branch bollwyvl/jupyterlab-lsp/gh-1079-settings-code-extractors |
As of opening this PR, things kinda work, e.g. this naive extractor finding {
"enabled": true,
"codeExtractors": {
"md-js-script": {
"hostLanguage": "ipythongfm",
"foreignLanguage": "javascript"
"pattern": "<script>((.|\n)*?(?=</script>))</script>",
"foreignCaptureGroups": [1],
"fileExtension": "js",
"cellTypes": ["code", "markdown"],
"isStandalone": false,
}
}
} Kinda, in that while diagnostics work, completion, go to definition, and others do not appear to work, but i haven't debugged further. The internal state of the upstream manager (and the extractor itself) is kind of hard to reason about, and generally requires a full page reload after making any changes. |
}, | ||
"foreignCaptureGroups": { | ||
"type": "array", | ||
"description": "Array of numbers specifying match groups to be extracted from the regular expression match, for the use in virtual document of the foreign language", |
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.
Apparently we aren't limited to integer-indexed groups:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Named_capturing_group#browser_compatibility
The syntax, alas, is not portable:
# python
r"(?P<name>.*)"
/* js */
/(?<name>.*)/
But still...
"properties": { | ||
"pattern": { | ||
"title": "Pattern", | ||
"type": "string", |
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.
Should likely consider allowing this to be an array of strings that get pre-concatenated.
References
Code changes
cellTypes
toRegExpForeignCodeExtractor.IOptions
schema/transclusions.json
to define a simplified extractorILSPCustomTransclusionsManager
tokenUser-facing changes
Backwards-incompatible changes
Chores