@@ -18,12 +18,20 @@ export const pgmlIndent = {
18
18
let i = 99 ;
19
19
let rank = 1 ;
20
20
21
- const answerRuleSnippet = snippetCompletion ( '[_${}]${}{${$answer}}' , {
22
- label : '[_]{ }' ,
23
- info : 'answer rule' ,
24
- section : { name : 'answer' , rank } ,
25
- boost : i --
26
- } ) ;
21
+ const answerRuleSnippets = [
22
+ snippetCompletion ( '[_${}]${}{${$answer}}${}' , {
23
+ label : '[_]{ }' ,
24
+ info : 'answer rule' ,
25
+ section : { name : 'answer' , rank } ,
26
+ boost : i --
27
+ } ) ,
28
+ snippetCompletion ( '[_${}]*{${$answer}}${}' , {
29
+ label : '[_]*{ }' ,
30
+ info : 'array answer rule' ,
31
+ section : { name : 'answer' , rank } ,
32
+ boost : i --
33
+ } )
34
+ ] ;
27
35
28
36
++ rank ;
29
37
const mathModeSnippets = [
@@ -32,7 +40,13 @@ const mathModeSnippets = [
32
40
[ '[``` ```]' , 'block display math' ] ,
33
41
[ '[: :]' , 'parsed inline math' ] ,
34
42
[ '[:: ::]' , 'parsed display style math' ] ,
35
- [ '[::: :::]' , 'parsed block display math' ]
43
+ [ '[::: :::]' , 'parsed block display math' ] ,
44
+ [ '[: :]*' , 'parsed inline math in active context' ] ,
45
+ [ '[:: ::]*' , 'parsed display style math in active context' ] ,
46
+ [ '[::: :::]*' , 'parsed block display math in active context' ] ,
47
+ [ '[: :]**' , 'parsed and reduced inline math in active context' ] ,
48
+ [ '[:: ::]**' , 'parsed and reduced display style math in active context' ] ,
49
+ [ '[::: :::]**' , 'parsed and reduced block display math in active context' ]
36
50
] . map ( ( [ label , info ] ) => {
37
51
return snippetCompletion ( label . replace ( ' ' , '${ }' ) + '${}' , {
38
52
label,
@@ -43,21 +57,95 @@ const mathModeSnippets = [
43
57
} ) ;
44
58
} ) ;
45
59
46
- const variableSnippet = snippetCompletion ( '[$${ }]${}' , {
47
- label : '[$ ]' ,
48
- info : 'variable' ,
49
- section : { name : 'substitution' , rank : ++ rank } ,
50
- type : 'variable' ,
51
- boost : i --
52
- } ) ;
60
+ const variableSnippets = [
61
+ snippetCompletion ( '[$${ }]${}' , {
62
+ label : '[$ ]' ,
63
+ info : 'variable' ,
64
+ section : { name : 'substitution' , rank : ++ rank } ,
65
+ type : 'variable' ,
66
+ boost : i --
67
+ } ) ,
68
+ snippetCompletion ( '[$${ }]*${}' , {
69
+ label : '[$ ]*' ,
70
+ info : 'variable with value not HTML escaped' ,
71
+ section : { name : 'substitution' , rank } ,
72
+ type : 'variable' ,
73
+ boost : i --
74
+ } ) ,
75
+ snippetCompletion ( '[$${ }]**${}' , {
76
+ label : '[$ ]**' ,
77
+ info : 'variable with value PGML parsed' ,
78
+ section : { name : 'substitution' , rank } ,
79
+ type : 'variable' ,
80
+ boost : i --
81
+ } ) ,
82
+ snippetCompletion ( '[$${ }]***${}' , {
83
+ label : '[$ ]***' ,
84
+ info : 'variable with LaTeX value not HTML escaped' ,
85
+ section : { name : 'substitution' , rank } ,
86
+ type : 'variable' ,
87
+ boost : i --
88
+ } )
89
+ ] ;
53
90
54
- const perlCommandSnippet = snippetCompletion ( '[@ ${ } @]${}' , {
55
- label : '[@ @]' ,
56
- info : 'perl command' ,
57
- section : { name : 'substitution' , rank } ,
58
- type : 'variable' ,
59
- boost : i --
60
- } ) ;
91
+ const perlCommandSnippets = [
92
+ snippetCompletion ( '[@ ${ } @]${}' , {
93
+ label : '[@ @]' ,
94
+ info : 'perl command' ,
95
+ section : { name : 'substitution' , rank } ,
96
+ type : 'variable' ,
97
+ boost : i --
98
+ } ) ,
99
+ snippetCompletion ( '[@ ${ } @]*${}' , {
100
+ label : '[@ @]*' ,
101
+ info : 'perl command with result not HTML escaped' ,
102
+ section : { name : 'substitution' , rank } ,
103
+ type : 'variable' ,
104
+ boost : i --
105
+ } ) ,
106
+ snippetCompletion ( '[@ ${ } @]**${}' , {
107
+ label : '[@ @]**' ,
108
+ info : 'perl command with result PGML parsed' ,
109
+ section : { name : 'substitution' , rank } ,
110
+ type : 'variable' ,
111
+ boost : i --
112
+ } ) ,
113
+ snippetCompletion ( '[@ ${ } @]***${}' , {
114
+ label : '[@ @]***' ,
115
+ info : 'perl command with LaTeX result not HTML escaped' ,
116
+ section : { name : 'substitution' , rank } ,
117
+ type : 'variable' ,
118
+ boost : i --
119
+ } ) ,
120
+ snippetCompletion ( '[@\n\t${ }\n@]${}' , {
121
+ label : '[@ @]' ,
122
+ info : 'perl command (multi line)' ,
123
+ section : { name : 'substitution' , rank } ,
124
+ type : 'variable' ,
125
+ boost : i --
126
+ } ) ,
127
+ snippetCompletion ( '[@\n\t${ }\n@]*${}' , {
128
+ label : '[@ @]*' ,
129
+ info : 'perl command with result not HTML escaped (multi line)' ,
130
+ section : { name : 'substitution' , rank } ,
131
+ type : 'variable' ,
132
+ boost : i --
133
+ } ) ,
134
+ snippetCompletion ( '[@\n\t${ }\n@]**${}' , {
135
+ label : '[@ @]**' ,
136
+ info : 'perl command with result PGML parsed (multi line)' ,
137
+ section : { name : 'substitution' , rank } ,
138
+ type : 'variable' ,
139
+ boost : i --
140
+ } ) ,
141
+ snippetCompletion ( '[@\n\t${ }\n@]***${}' , {
142
+ label : '[@ @]***' ,
143
+ info : 'perl command with LaTeX result not HTML escaped (multi line)' ,
144
+ section : { name : 'substitution' , rank } ,
145
+ type : 'variable' ,
146
+ boost : i --
147
+ } )
148
+ ] ;
61
149
62
150
const imageSnippet = snippetCompletion ( '[!${alt text}!]{${$source}}${}' , {
63
151
label : '[! !]{ }' ,
@@ -83,26 +171,60 @@ const commentSnippet = snippetCompletion('[% ${ } %]${}', {
83
171
boost : i --
84
172
} ) ;
85
173
86
- const tableSnippet = snippetCompletion ( '[#${ }#]${}' , {
87
- label : '[# #]' ,
88
- info : 'table' ,
89
- section : { name : 'table' , rank : ++ rank } ,
90
- type : 'type' ,
91
- boost : i --
92
- } ) ;
174
+ const tableSnippets = [
175
+ snippetCompletion ( '[#\n\t[.${ }.]${}\n#]${}' , {
176
+ label : '[# [. .] #]' ,
177
+ info : 'table (multi line)' ,
178
+ section : { name : 'table' , rank : ++ rank } ,
179
+ type : 'type' ,
180
+ boost : i --
181
+ } ) ,
182
+ snippetCompletion ( '[#\n\t[.${ }.]${}\n#]*${}' , {
183
+ label : '[# [. .] #]*' ,
184
+ info : 'layout table (multi line)' ,
185
+ section : { name : 'table' , rank } ,
186
+ type : 'type' ,
187
+ boost : i --
188
+ } ) ,
189
+ snippetCompletion ( '[# [.${ }.]${} #]${}' , {
190
+ label : '[# [. .] #]' ,
191
+ info : 'table (single line)' ,
192
+ section : { name : 'table' , rank } ,
193
+ type : 'type' ,
194
+ boost : i --
195
+ } ) ,
196
+ snippetCompletion ( '[# [.${ }.]${} #]*${}' , {
197
+ label : '[# [. .] #]*' ,
198
+ info : 'layout table (single line)' ,
199
+ section : { name : 'table' , rank } ,
200
+ type : 'type' ,
201
+ boost : i --
202
+ } )
203
+ ] ;
93
204
94
- const tableCellSnippet = snippetCompletion ( '[.${ }.]${}' , {
95
- label : '[. .]' ,
96
- info : 'table cell' ,
97
- section : { name : 'table' , rank } ,
98
- type : 'type' ,
99
- boost : i --
100
- } ) ;
205
+ const tableCellSnippets = [
206
+ snippetCompletion ( '[.${ }.]${}' , {
207
+ label : '[. .]' ,
208
+ info : 'table cell' ,
209
+ section : { name : 'table' , rank } ,
210
+ type : 'type' ,
211
+ boost : i --
212
+ } ) ,
213
+ snippetCompletion ( '[.${ }.]*${}' , {
214
+ label : '[. .]' ,
215
+ info : 'table cell at end of table row' ,
216
+ section : { name : 'table' , rank } ,
217
+ type : 'type' ,
218
+ boost : i --
219
+ } )
220
+ ] ;
101
221
102
222
++ rank ;
103
223
const verbatimSnippets = [
104
224
[ '[| |]' , 'verbatim' ] ,
105
- [ '[|| ||]' , 'verbatim with unprocessed inner verbatim' ]
225
+ [ '[| |]*' , 'verbatim code' ] ,
226
+ [ '[|| ||]' , 'verbatim with unprocessed inner verbatim' ] ,
227
+ [ '[|| ||]*' , 'verbatim code with unprocessed inner verbatim' ]
106
228
] . map ( ( [ label , info ] ) => {
107
229
return snippetCompletion ( label . replace ( ' ' , '${ }' ) + '${}' , {
108
230
label,
@@ -148,12 +270,13 @@ export const pgmlLanguageData = {
148
270
const insideTable = inside ( 'Table' ) ;
149
271
if (
150
272
( insideTable == 2 || ( insideTable == 1 && ( ! textBefore . endsWith ( '[#' ) || / ^ \s * # \] / . test ( textAfter ) ) ) ) &&
151
- ( ! inside ( 'TableCell' ) || ( textBefore . endsWith ( '[.' ) && ! / ^ [ \t ] * .\] / . test ( textAfter ) ) )
273
+ ( ( ! inside ( 'TableCell' ) && ! textBefore . endsWith ( '.]*' ) ) ||
274
+ ( textBefore . endsWith ( '[.' ) && ! / ^ [ \t ] * \. \] / . test ( textAfter ) ) )
152
275
) {
153
276
const previous = context . matchBefore ( / \[ | \[ \. / ) ;
154
277
return {
155
278
from : previous ?. from ?? context . pos ,
156
- options : [ tableCellSnippet ]
279
+ options : tableCellSnippets
157
280
} ;
158
281
}
159
282
@@ -168,7 +291,7 @@ export const pgmlLanguageData = {
168
291
if ( ! previous && ! context . explicit ) return ;
169
292
return {
170
293
from : previous ?. from ?? context . pos ,
171
- options : [ variableSnippet , perlCommandSnippet ]
294
+ options : [ ... variableSnippets , ... perlCommandSnippets ]
172
295
} ;
173
296
}
174
297
@@ -178,7 +301,7 @@ export const pgmlLanguageData = {
178
301
if ( ! previous && ! context . explicit ) return ;
179
302
return {
180
303
from : previous ?. from ?? context . pos ,
181
- options : [ variableSnippet , perlCommandSnippet ]
304
+ options : [ ... variableSnippets , ... perlCommandSnippets ]
182
305
} ;
183
306
}
184
307
@@ -196,14 +319,14 @@ export const pgmlLanguageData = {
196
319
return {
197
320
from : previous ?. from ?? context . pos ,
198
321
options : [
199
- answerRuleSnippet ,
322
+ ... answerRuleSnippets ,
200
323
...mathModeSnippets ,
201
- variableSnippet ,
202
- perlCommandSnippet ,
324
+ ... variableSnippets ,
325
+ ... perlCommandSnippets ,
203
326
imageSnippet ,
204
327
tagSnippet ,
205
328
commentSnippet ,
206
- tableSnippet ,
329
+ ... tableSnippets ,
207
330
...verbatimSnippets
208
331
]
209
332
} ;
@@ -222,14 +345,14 @@ export const pgmlLanguageData = {
222
345
return {
223
346
from : context . pos ,
224
347
options : [
225
- answerRuleSnippet ,
348
+ ... answerRuleSnippets ,
226
349
...mathModeSnippets ,
227
- variableSnippet ,
228
- perlCommandSnippet ,
350
+ ... variableSnippets ,
351
+ ... perlCommandSnippets ,
229
352
imageSnippet ,
230
353
tagSnippet ,
231
354
commentSnippet ,
232
- tableSnippet ,
355
+ ... tableSnippets ,
233
356
...verbatimSnippets ,
234
357
preSnippet
235
358
]
0 commit comments