Open
Description
Elevator Pitch
Offer an appropriate place in settings to define new extractors via JSON schema.
Motivation
The existing hard-coded extractors are a fairly inflexible way to extend the system.
This would allow a non-TS system to extend
Design Ideas
- add a mapping of
RegExpForeignCodeExtractor.IOptions
(plus arank
) to the right plugin's settings schema:
"definitions": {
"code-extractors": {
"type": "object",
"title": "Code Extractors",
"description": "descriptions of how to find other language blocks, keyed by host language",
"additionalProperties": {
"$ref": "#/definitions/host-code-extractors"
}
},
"host-code-extractors": {
"type": "object",
"descirption": "code extractors for a single host language, keyed by regular expression",
"additionalProperties": {
"$ref": "#/definitions/codeExtractor"
}
},
"code-extractor": {
"type": "object",
"properties": {
"language": {
"type": "string",
"description": "the guest language for the code that is extracted"
},
"...etc": {}
}
}
}
With an example:
new RegExpForeignCodeExtractor({
language: 'javascript',
pattern: '^%%(js|javascript)( .*?)?\n([^]*)',
foreignCaptureGroups: [3],
isStandalone: false,
fileExtension: 'js'
}),
represented as:
{
"codeExtractors": {
"python": {
"^%%(js|javascript)( .*?)?\n([^]*)": {
"language": "javascript",
"foreignCaptureGroups": [3],
"isStandalone": false,
"fileExtension": "js",
"rank": 100
}
}
}
}
- use mapping at startup time, probably need to handle dynamism
- move existing hard-coded ones to schema defaults
Metadata
Assignees
Labels
No labels