forked from jupyter-lsp/jupyterlab-lsp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
defaults.ts
96 lines (95 loc) · 2.85 KB
/
defaults.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import { IForeignCodeExtractorsRegistry } from './types';
import { RegExpForeignCodeExtractor } from './regexp';
// TODO: make the regex code extractors configurable
export let foreign_code_extractors: IForeignCodeExtractorsRegistry = {
// general note: to match new lines use [^] instead of dot, unless the target is ES2018, then use /s
python: [
//
// R magics (non-standalone: the R code will always be in the same, single R-namespace)
//
new RegExpForeignCodeExtractor({
language: 'R',
pattern: '^%%R( .*?)?\n([^]*)',
extract_to_foreign: '$2',
keep_in_host: true,
is_standalone: false
}),
new RegExpForeignCodeExtractor({
language: 'R',
pattern: '(^|\n)%R (.*)\n?',
extract_to_foreign: '$2',
keep_in_host: true,
is_standalone: false
}),
//
// Standalone IPython magics
// (script magics are standalone, i.e. consecutive code cells with the same magic create two different namespaces)
//
new RegExpForeignCodeExtractor({
language: 'python',
pattern: '^%%(python|python2|python3|pypy)( .*?)?\n([^]*)',
extract_to_foreign: '$3',
keep_in_host: false,
is_standalone: true
}),
new RegExpForeignCodeExtractor({
language: 'perl',
pattern: '^%%(perl)( .*?)?\n([^]*)',
extract_to_foreign: '$3',
keep_in_host: false,
is_standalone: true
}),
new RegExpForeignCodeExtractor({
language: 'ruby',
pattern: '^%%(ruby)( .*?)?\n([^]*)',
extract_to_foreign: '$3',
keep_in_host: false,
is_standalone: true
}),
new RegExpForeignCodeExtractor({
language: 'sh',
pattern: '^%%(sh)( .*?)?\n([^]*)',
extract_to_foreign: '$3',
keep_in_host: false,
is_standalone: true
}),
new RegExpForeignCodeExtractor({
language: 'html',
pattern: '^%%(html --isolated)( .*?)?\n([^]*)',
extract_to_foreign: '$3',
keep_in_host: false,
is_standalone: true
}),
//
// IPython magics producing continuous documents (non-standalone):
//
new RegExpForeignCodeExtractor({
language: 'js',
pattern: '^%%(js|javascript)( .*?)?\n([^]*)',
extract_to_foreign: '$3',
keep_in_host: false,
is_standalone: false
}),
new RegExpForeignCodeExtractor({
language: 'html',
pattern: '^%%(html)( .*?)?\n([^]*)',
extract_to_foreign: '$3',
keep_in_host: false,
is_standalone: false
}),
new RegExpForeignCodeExtractor({
language: 'latex',
pattern: '^%%(latex)( .*?)?\n([^]*)',
extract_to_foreign: '$3',
keep_in_host: false,
is_standalone: false
}),
new RegExpForeignCodeExtractor({
language: 'markdown',
pattern: '^%%(markdown)( .*?)?\n([^]*)',
extract_to_foreign: '$3',
keep_in_host: false,
is_standalone: false
})
]
};