[wip] add settings-based code extractors#1080
[wip] add settings-based code extractors#1080bollwyvl wants to merge 1 commit intojupyter-lsp:mainfrom
Conversation
|
|
|
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.
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.
Should likely consider allowing this to be an array of strings that get pre-concatenated.

References
Code changes
cellTypestoRegExpForeignCodeExtractor.IOptionsschema/transclusions.jsonto define a simplified extractorILSPCustomTransclusionsManagertokenUser-facing changes
Backwards-incompatible changes
Chores