wikilint 2.28.0 → 2.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/config/default.json +15 -16
  2. package/config/jawiki.json +15 -16
  3. package/data/ext/ThirdPartyNotices.txt +33 -0
  4. package/data/ext/mapframe.json +489 -2
  5. package/dist/base.d.mts +4 -2
  6. package/dist/base.d.ts +4 -2
  7. package/dist/base.js +2 -0
  8. package/dist/base.mjs +3 -1
  9. package/dist/bin/config.js +11 -11
  10. package/dist/index.d.ts +2 -1
  11. package/dist/index.js +23 -2
  12. package/dist/lib/document.d.ts +23 -7
  13. package/dist/lib/document.js +7 -27
  14. package/dist/lib/element.js +1 -1
  15. package/dist/lib/lintConfig.js +4 -0
  16. package/dist/lib/lsp.d.ts +1 -12
  17. package/dist/lib/lsp.js +45 -76
  18. package/dist/lib/node.js +23 -20
  19. package/dist/lib/title.d.ts +3 -1
  20. package/dist/lib/title.js +37 -9
  21. package/dist/mixin/elementLike.js +14 -9
  22. package/dist/parser/commentAndExt.js +34 -27
  23. package/dist/parser/hrAndDoubleUnderscore.js +8 -7
  24. package/dist/parser/links.js +4 -3
  25. package/dist/parser/redirect.js +1 -1
  26. package/dist/parser/selector.js +6 -8
  27. package/dist/src/arg.js +4 -5
  28. package/dist/src/attribute.js +28 -0
  29. package/dist/src/attributes.js +1 -1
  30. package/dist/src/converter.js +6 -3
  31. package/dist/src/imageParameter.d.ts +3 -1
  32. package/dist/src/imageParameter.js +65 -11
  33. package/dist/src/index.d.ts +8 -0
  34. package/dist/src/index.js +21 -28
  35. package/dist/src/link/file.js +8 -11
  36. package/dist/src/link/galleryImage.js +1 -1
  37. package/dist/src/link/redirectTarget.js +1 -1
  38. package/dist/src/magicLink.js +12 -1
  39. package/dist/src/multiLine/gallery.js +2 -2
  40. package/dist/src/multiLine/imagemap.js +3 -4
  41. package/dist/src/multiLine/paramTag.js +2 -2
  42. package/dist/src/nowiki/doubleUnderscore.d.ts +3 -1
  43. package/dist/src/nowiki/doubleUnderscore.js +6 -2
  44. package/dist/src/nowiki/index.js +59 -2
  45. package/dist/src/table/base.js +1 -2
  46. package/dist/src/table/index.js +1 -2
  47. package/dist/src/tagPair/ext.js +10 -3
  48. package/dist/src/transclude.js +3 -3
  49. package/dist/util/constants.js +3 -1
  50. package/dist/util/debug.js +1 -1
  51. package/dist/util/search.js +16 -0
  52. package/dist/util/sharable.js +27 -3
  53. package/dist/util/sharable.mjs +28 -4
  54. package/i18n/en.json +4 -0
  55. package/i18n/zh-hans.json +4 -0
  56. package/i18n/zh-hant.json +4 -0
  57. package/package.json +8 -6
  58. package/data/ext/maplink.json +0 -4
@@ -1,4 +1,491 @@
1
1
  {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$ref": "https://geojson.org/schema/GeoJSON.json"
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+ "id": "http://json-schema.org/geojson/geojson.json#",
4
+ "oneOf": [
5
+ {
6
+ "$ref": "#/definitions/root"
7
+ },
8
+ {
9
+ "type": "array",
10
+ "items": {
11
+ "$ref": "#/definitions/root"
12
+ }
13
+ }
14
+ ],
15
+ "definitions": {
16
+ "root": {
17
+ "title": "Geo JSON object",
18
+ "description": "Schema for a Geo JSON object",
19
+ "type": "object",
20
+ "required": [
21
+ "type"
22
+ ],
23
+ "properties": {
24
+ "crs": {
25
+ "$ref": "#/definitions/crs"
26
+ },
27
+ "bbox": {
28
+ "$ref": "#/definitions/bbox"
29
+ }
30
+ },
31
+ "oneOf": [
32
+ {
33
+ "$ref": "#/definitions/geometry"
34
+ },
35
+ {
36
+ "$ref": "#/definitions/feature"
37
+ },
38
+ {
39
+ "$ref": "#/definitions/featureCollection"
40
+ },
41
+ {
42
+ "$ref": "#/definitions/externalData"
43
+ }
44
+ ]
45
+ },
46
+ "crs": {
47
+ "title": "crs",
48
+ "description": "a Coordinate Reference System object",
49
+ "type": [
50
+ "object",
51
+ "null"
52
+ ],
53
+ "required": [
54
+ "type",
55
+ "properties"
56
+ ],
57
+ "properties": {
58
+ "type": {
59
+ "type": "string"
60
+ },
61
+ "properties": {
62
+ "type": "object"
63
+ }
64
+ },
65
+ "additionalProperties": false,
66
+ "oneOf": [
67
+ {
68
+ "$ref": "#/definitions/namedCrs"
69
+ },
70
+ {
71
+ "$ref": "#/definitions/linkedCrs"
72
+ }
73
+ ]
74
+ },
75
+ "bbox": {
76
+ "description": "A bounding box as defined by GeoJSON",
77
+ "FIXME": "unenforceable constraint: even number of elements in array",
78
+ "type": "array",
79
+ "items": {
80
+ "type": "number"
81
+ }
82
+ },
83
+ "geometry": {
84
+ "title": "geometry",
85
+ "description": "One geometry as defined by GeoJSON",
86
+ "type": "object",
87
+ "required": [
88
+ "type"
89
+ ],
90
+ "oneOf": [
91
+ {
92
+ "$ref": "#/definitions/primitiveGeometry"
93
+ },
94
+ {
95
+ "$ref": "#/definitions/geometryCollection"
96
+ }
97
+ ]
98
+ },
99
+ "primitiveGeometry": {
100
+ "title": "primitiveGeometry",
101
+ "description": "All the non-collection Geometry types",
102
+ "type": "object",
103
+ "required": [
104
+ "coordinates"
105
+ ],
106
+ "oneOf": [
107
+ {
108
+ "title": "Point",
109
+ "properties": {
110
+ "type": {
111
+ "enum": [
112
+ "Point"
113
+ ]
114
+ },
115
+ "coordinates": {
116
+ "$ref": "#/definitions/position"
117
+ }
118
+ }
119
+ },
120
+ {
121
+ "title": "MultiPoint",
122
+ "properties": {
123
+ "type": {
124
+ "enum": [
125
+ "MultiPoint"
126
+ ]
127
+ },
128
+ "coordinates": {
129
+ "$ref": "#/definitions/positionArray"
130
+ }
131
+ }
132
+ },
133
+ {
134
+ "title": "LineString",
135
+ "properties": {
136
+ "type": {
137
+ "enum": [
138
+ "LineString"
139
+ ]
140
+ },
141
+ "coordinates": {
142
+ "$ref": "#/definitions/lineString"
143
+ }
144
+ }
145
+ },
146
+ {
147
+ "title": "MultiLineString",
148
+ "properties": {
149
+ "type": {
150
+ "enum": [
151
+ "MultiLineString"
152
+ ]
153
+ },
154
+ "coordinates": {
155
+ "type": "array",
156
+ "items": {
157
+ "$ref": "#/definitions/lineString"
158
+ }
159
+ }
160
+ }
161
+ },
162
+ {
163
+ "title": "Polygon",
164
+ "properties": {
165
+ "type": {
166
+ "enum": [
167
+ "Polygon"
168
+ ]
169
+ },
170
+ "coordinates": {
171
+ "$ref": "#/definitions/polygon"
172
+ }
173
+ }
174
+ },
175
+ {
176
+ "title": "MultiPolygon",
177
+ "properties": {
178
+ "type": {
179
+ "enum": [
180
+ "MultiPolygon"
181
+ ]
182
+ },
183
+ "coordinates": {
184
+ "type": "array",
185
+ "items": {
186
+ "$ref": "#/definitions/polygon"
187
+ }
188
+ }
189
+ }
190
+ }
191
+ ]
192
+ },
193
+ "geometryCollection": {
194
+ "title": "GeometryCollection",
195
+ "description": "A collection of geometry objects",
196
+ "required": [
197
+ "geometries"
198
+ ],
199
+ "properties": {
200
+ "type": {
201
+ "enum": [
202
+ "GeometryCollection"
203
+ ]
204
+ },
205
+ "geometries": {
206
+ "type": "array",
207
+ "items": {
208
+ "$ref": "#/definitions/geometry"
209
+ }
210
+ }
211
+ }
212
+ },
213
+ "feature": {
214
+ "title": "Feature",
215
+ "description": "A Geo JSON feature object",
216
+ "required": [
217
+ "geometry"
218
+ ],
219
+ "properties": {
220
+ "type": {
221
+ "enum": [
222
+ "Feature"
223
+ ]
224
+ },
225
+ "geometry": {
226
+ "oneOf": [
227
+ {
228
+ "type": "null"
229
+ },
230
+ {
231
+ "$ref": "#/definitions/geometry"
232
+ }
233
+ ]
234
+ },
235
+ "properties": {
236
+ "$ref": "#/definitions/simplestyle"
237
+ },
238
+ "id": {
239
+ "type": [
240
+ "string",
241
+ "number"
242
+ ]
243
+ }
244
+ }
245
+ },
246
+ "featureCollection": {
247
+ "title": "FeatureCollection",
248
+ "description": "A Geo JSON feature collection",
249
+ "required": [
250
+ "features"
251
+ ],
252
+ "properties": {
253
+ "type": {
254
+ "enum": [
255
+ "FeatureCollection"
256
+ ]
257
+ },
258
+ "features": {
259
+ "type": "array",
260
+ "items": {
261
+ "$ref": "#/definitions/feature"
262
+ }
263
+ }
264
+ }
265
+ },
266
+ "externalData": {
267
+ "title": "ExternalData",
268
+ "description": "WMF extension - reference to external geometries",
269
+ "required": [
270
+ "type",
271
+ "service"
272
+ ],
273
+ "oneOf": [
274
+ {
275
+ "required": [
276
+ "title"
277
+ ],
278
+ "properties": {
279
+ "service": {
280
+ "enum": [
281
+ "page"
282
+ ]
283
+ },
284
+ "title": {
285
+ "type": "string"
286
+ }
287
+ }
288
+ },
289
+ {
290
+ "anyOf": [
291
+ {
292
+ "required": [
293
+ "query"
294
+ ]
295
+ },
296
+ {
297
+ "required": [
298
+ "ids"
299
+ ]
300
+ }
301
+ ],
302
+ "properties": {
303
+ "service": {
304
+ "enum": [
305
+ "geoshape",
306
+ "geoline",
307
+ "geopoint",
308
+ "geomask"
309
+ ]
310
+ },
311
+ "query": {
312
+ "type": "string"
313
+ },
314
+ "ids": {
315
+ "oneOf": [
316
+ {
317
+ "type": "array",
318
+ "items": {
319
+ "type": "string",
320
+ "pattern": "^Q[1-9]\\d{0,19}$"
321
+ }
322
+ },
323
+ {
324
+ "type": "string",
325
+ "pattern": "^Q[1-9]\\d{0,19}(\\s*,\\s*Q[1-9]\\d{0,19})*$"
326
+ }
327
+ ]
328
+ }
329
+ }
330
+ }
331
+ ],
332
+ "properties": {
333
+ "type": {
334
+ "enum": [
335
+ "ExternalData"
336
+ ]
337
+ },
338
+ "service": {
339
+ "type": "string"
340
+ },
341
+ "properties": {
342
+ "$ref": "#/definitions/simplestyle"
343
+ }
344
+ }
345
+ },
346
+ "position": {
347
+ "description": "A single position",
348
+ "type": "array",
349
+ "minItems": 2,
350
+ "items": {
351
+ "type": "number"
352
+ }
353
+ },
354
+ "positionArray": {
355
+ "description": "An array of positions",
356
+ "type": "array",
357
+ "items": {
358
+ "$ref": "#/definitions/position"
359
+ }
360
+ },
361
+ "lineString": {
362
+ "description": "An array of two or more positions",
363
+ "allOf": [
364
+ {
365
+ "$ref": "#/definitions/positionArray"
366
+ },
367
+ {
368
+ "minItems": 2
369
+ }
370
+ ]
371
+ },
372
+ "linearRing": {
373
+ "description": "An array of four positions where the first equals the last",
374
+ "allOf": [
375
+ {
376
+ "$ref": "#/definitions/positionArray"
377
+ },
378
+ {
379
+ "minItems": 4
380
+ }
381
+ ]
382
+ },
383
+ "polygon": {
384
+ "description": "An array of linear rings",
385
+ "type": "array",
386
+ "items": {
387
+ "$ref": "#/definitions/linearRing"
388
+ }
389
+ },
390
+ "namedCrs": {
391
+ "properties": {
392
+ "type": {
393
+ "enum": [
394
+ "name"
395
+ ]
396
+ },
397
+ "properties": {
398
+ "required": [
399
+ "name"
400
+ ],
401
+ "additionalProperties": false,
402
+ "properties": {
403
+ "name": {
404
+ "type": "string",
405
+ "FIXME": "semantic validation necessary"
406
+ }
407
+ }
408
+ }
409
+ }
410
+ },
411
+ "linkedObject": {
412
+ "type": "object",
413
+ "required": [
414
+ "href"
415
+ ],
416
+ "properties": {
417
+ "href": {
418
+ "type": "string",
419
+ "format": "uri",
420
+ "FIXME": "spec says \"dereferenceable\", cannot enforce that"
421
+ },
422
+ "type": {
423
+ "type": "string",
424
+ "description": "Suggested values: proj4, ogjwkt, esriwkt"
425
+ }
426
+ }
427
+ },
428
+ "linkedCrs": {
429
+ "properties": {
430
+ "type": {
431
+ "enum": [
432
+ "link"
433
+ ]
434
+ },
435
+ "properties": {
436
+ "$ref": "#/definitions/linkedObject"
437
+ }
438
+ }
439
+ },
440
+ "simplestyle": {
441
+ "type": "object",
442
+ "properties": {
443
+ "title": {
444
+ "type": "string"
445
+ },
446
+ "description": {
447
+ "type": "string"
448
+ },
449
+ "marker-size": {
450
+ "enum": [
451
+ "small",
452
+ "medium",
453
+ "large"
454
+ ]
455
+ },
456
+ "marker-symbol": {
457
+ "type": "string",
458
+ "pattern": "^(|[a-zA-Z0-9-]+)$"
459
+ },
460
+ "marker-color": {
461
+ "$ref": "#/definitions/color"
462
+ },
463
+ "stroke": {
464
+ "$ref": "#/definitions/color"
465
+ },
466
+ "stroke-opacity": {
467
+ "$ref": "#/definitions/opacity"
468
+ },
469
+ "stroke-width": {
470
+ "type": "number",
471
+ "minimum": 0
472
+ },
473
+ "fill": {
474
+ "$ref": "#/definitions/color"
475
+ },
476
+ "fill-opacity": {
477
+ "$ref": "#/definitions/opacity"
478
+ }
479
+ }
480
+ },
481
+ "color": {
482
+ "type": "string",
483
+ "pattern": "^#?([0-9a-fA-F]{3}){1,2}$"
484
+ },
485
+ "opacity": {
486
+ "type": "number",
487
+ "minimum": 0,
488
+ "maximum": 1
489
+ }
490
+ }
4
491
  }
package/dist/base.d.mts CHANGED
@@ -45,7 +45,7 @@ export declare const stages: {
45
45
  'list-range': number;
46
46
  };
47
47
  export type Stage = keyof typeof stages;
48
- export declare const rules: readonly ["bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext", "invalid-css"];
48
+ export declare const rules: readonly ["bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "invalid-url", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext", "invalid-css", "invalid-math"];
49
49
  export declare namespace LintError {
50
50
  type Severity = 'error' | 'warning';
51
51
  type Rule = typeof rules[number];
@@ -304,8 +304,10 @@ export interface Parser {
304
304
  * 解析wikitext
305
305
  * @param include whether to be transcluded / 是否嵌入
306
306
  * @param maxStage max stage for parsing / 最大解析层级
307
+ * @param page page name / 页面名称
307
308
  */
308
- parse(wikitext: string, include?: boolean, maxStage?: number | Stage | Stage[], config?: Config): Token;
309
+ parse(wikitext: string, include?: boolean, maxStage?: number | Stage | Stage[], config?: Config, page?: string): Token;
310
+ parse(wikitext: string, page: string, include?: boolean, maxStage?: number | Stage | Stage[], config?: Config): Token;
309
311
  /**
310
312
  * Create a language server
311
313
  *
package/dist/base.d.ts CHANGED
@@ -45,7 +45,7 @@ export declare const stages: {
45
45
  'list-range': number;
46
46
  };
47
47
  export type Stage = keyof typeof stages;
48
- export declare const rules: readonly ["bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext", "invalid-css"];
48
+ export declare const rules: readonly ["bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "invalid-url", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext", "invalid-css", "invalid-math"];
49
49
  export declare namespace LintError {
50
50
  type Severity = 'error' | 'warning';
51
51
  type Rule = typeof rules[number];
@@ -304,8 +304,10 @@ export interface Parser {
304
304
  * 解析wikitext
305
305
  * @param include whether to be transcluded / 是否嵌入
306
306
  * @param maxStage max stage for parsing / 最大解析层级
307
+ * @param page page name / 页面名称
307
308
  */
308
- parse(wikitext: string, include?: boolean, maxStage?: number | Stage | Stage[], config?: Config): Token;
309
+ parse(wikitext: string, include?: boolean, maxStage?: number | Stage | Stage[], config?: Config, page?: string): Token;
310
+ parse(wikitext: string, page: string, include?: boolean, maxStage?: number | Stage | Stage[], config?: Config): Token;
309
311
  /**
310
312
  * Create a language server
311
313
  *
package/dist/base.js CHANGED
@@ -44,6 +44,7 @@ exports.rules = (() => {
44
44
  'invalid-imagemap',
45
45
  'invalid-invoke',
46
46
  'invalid-isbn',
47
+ 'invalid-url',
47
48
  'lonely-apos',
48
49
  'lonely-bracket',
49
50
  'lonely-http',
@@ -70,6 +71,7 @@ exports.rules = (() => {
70
71
  'void-ext',
71
72
  /* NOT FOR BROWSER ONLY */
72
73
  'invalid-css',
74
+ 'invalid-math',
73
75
  ];
74
76
  Object.freeze(arr);
75
77
  return arr;
package/dist/base.mjs CHANGED
@@ -41,6 +41,7 @@ const rules = /* @__PURE__ */ (() => {
41
41
  "invalid-imagemap",
42
42
  "invalid-invoke",
43
43
  "invalid-isbn",
44
+ "invalid-url",
44
45
  "lonely-apos",
45
46
  "lonely-bracket",
46
47
  "lonely-http",
@@ -66,7 +67,8 @@ const rules = /* @__PURE__ */ (() => {
66
67
  "var-anchor",
67
68
  "void-ext",
68
69
  /* NOT FOR BROWSER ONLY */
69
- "invalid-css"
70
+ "invalid-css",
71
+ "invalid-math"
70
72
  ];
71
73
  Object.freeze(arr);
72
74
  return arr;
@@ -77,7 +77,7 @@ const mw = {
77
77
  },
78
78
  },
79
79
  };
80
- const pkg = "wikilint", version = "2.28.0";
80
+ const pkg = "wikilint", version = "2.29.0";
81
81
  let mwConfig;
82
82
  /**
83
83
  * Get the parser configuration for a Wikimedia Foundation project.
@@ -147,12 +147,12 @@ exports.default = async (site, url, user, force, internal) => {
147
147
  ...namespacealiases.filter(({ id }) => filterGadget(id)).map(({ id, alias }) => [alias.toLowerCase(), id]),
148
148
  ]),
149
149
  articlePath: articlepath,
150
- };
151
- config.doubleUnderscore[0] = [];
152
- config.doubleUnderscore[1] = [];
153
- Object.assign(config.parserFunction[0], (0, cm_util_1.getConfig)(magicwords, ({ name }) => name === 'msgnw'));
154
- config.parserFunction[2] = getAliases(magicwords, new Set(['msg', 'raw']));
155
- config.parserFunction[3] = getAliases(magicwords, new Set(['subst', 'safesubst']));
150
+ }, { doubleUnderscore, parserFunction, variable } = config;
151
+ doubleUnderscore[0] = [];
152
+ doubleUnderscore[1] = [];
153
+ Object.assign(parserFunction[0], (0, cm_util_1.getConfig)(magicwords, ({ name }) => name === 'msgnw'));
154
+ parserFunction[2] = getAliases(magicwords, new Set(['msg', 'raw']));
155
+ parserFunction[3] = getAliases(magicwords, new Set(['subst', 'safesubst']));
156
156
  if (!mwConfig.functionHooks) {
157
157
  Object.assign(config, { functionHook: [...functionhooks.map(s => s.toLowerCase()), 'msgnw'] });
158
158
  }
@@ -160,11 +160,11 @@ exports.default = async (site, url, user, force, internal) => {
160
160
  const { query: { variables } } = await (await fetch(`${url}/api.php?${new URLSearchParams({ ...params, siprop: 'variables' }).toString()}`, headers)).json();
161
161
  Object.assign(config, { variable: [...new Set([...variables, '='])] });
162
162
  }
163
- if ('#choose' in config.parserFunction[0]) {
164
- delete config.parserFunction[0]['choose'];
165
- const i = config.variable.indexOf('choose');
163
+ if ('#choose' in parserFunction[0]) {
164
+ delete parserFunction[0]['choose'];
165
+ const i = variable.indexOf('choose');
166
166
  if (i !== -1) {
167
- config.variable.splice(i, 1);
167
+ variable.splice(i, 1);
168
168
  }
169
169
  }
170
170
  // saving configuration
package/dist/index.d.ts CHANGED
@@ -17,7 +17,8 @@ declare interface Parser extends ParserBase {
17
17
  * @param include whether to be transcluded / 是否嵌入
18
18
  */
19
19
  normalizeTitle(title: string, defaultNs?: number, include?: boolean, config?: Config): Title;
20
- parse(wikitext: string, include?: boolean, maxStage?: number | Stage | Stage[], config?: Config): Token;
20
+ parse(wikitext: string, include?: boolean, maxStage?: number | Stage | Stage[], config?: Config, page?: string): Token;
21
+ parse(wikitext: string, page: string, include?: boolean, maxStage?: number | Stage | Stage[], config?: Config): Token;
21
22
  /**
22
23
  * Create a language server
23
24
  *
package/dist/index.js CHANGED
@@ -132,6 +132,7 @@ const Parser = {
132
132
  titleObj = debug_1.Shadow.run(() => {
133
133
  const root = new Token(title, config);
134
134
  root.type = 'root';
135
+ root.pageName = opt?.page;
135
136
  root.parseOnce(0, include).parseOnce();
136
137
  const t = new Title(root.toString(), defaultNs, config, opt);
137
138
  root.build();
@@ -153,8 +154,23 @@ const Parser = {
153
154
  return titleObj;
154
155
  },
155
156
  /** @implements */
156
- parse(wikitext, include, maxStage = constants_1.MAX_STAGE, config = Parser.getConfig()) {
157
+ parse(wikitext, includeOrPage, maxStageOrInclude, configOrStage, pageOrConfig) {
157
158
  wikitext = (0, string_1.tidy)(wikitext);
159
+ let include, maxStage, config, page;
160
+ if (typeof includeOrPage === 'string') {
161
+ include = Boolean(maxStageOrInclude);
162
+ maxStage = configOrStage;
163
+ config = pageOrConfig;
164
+ page = includeOrPage;
165
+ }
166
+ else {
167
+ include = Boolean(includeOrPage);
168
+ maxStage = maxStageOrInclude;
169
+ config = configOrStage;
170
+ page = pageOrConfig;
171
+ }
172
+ maxStage ??= constants_1.MAX_STAGE;
173
+ config ??= this.getConfig();
158
174
  let types;
159
175
  LINT: { // eslint-disable-line no-unused-labels
160
176
  if (typeof maxStage !== 'number') {
@@ -166,6 +182,7 @@ const Parser = {
166
182
  const root = debug_1.Shadow.run(() => {
167
183
  const token = new Token(wikitext, config);
168
184
  token.type = 'root';
185
+ token.pageName = page;
169
186
  try {
170
187
  return token.parse(maxStage, include);
171
188
  /* NOT FOR BROWSER ONLY */
@@ -180,7 +197,7 @@ const Parser = {
180
197
  }
181
198
  fs_1.default.writeFileSync(file, stage === constants_1.MAX_STAGE ? wikitext : token.toString());
182
199
  fs_1.default.writeFileSync(`${file}.err`, e.stack);
183
- fs_1.default.writeFileSync(`${file}.json`, JSON.stringify({ stage, include, config }, null, '\t'));
200
+ fs_1.default.writeFileSync(`${file}.json`, JSON.stringify({ stage, include, config, page }, null, '\t'));
184
201
  }
185
202
  throw e;
186
203
  }
@@ -189,6 +206,10 @@ const Parser = {
189
206
  return root;
190
207
  },
191
208
  /** @implements */
209
+ parseWithRef(wikitext, ref, maxStage, include = ref.getAttribute('include')) {
210
+ return this.parse(wikitext, include, maxStage, ref.getAttribute('config'), ref.pageName);
211
+ },
212
+ /** @implements */
192
213
  async partialParse(wikitext, watch, include, config = Parser.getConfig()) {
193
214
  LSP: { // eslint-disable-line no-unused-labels
194
215
  const { Token } = require('./src/index');