wikiparser-node 1.16.6 → 1.17.1

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 (98) hide show
  1. package/README.md +1 -0
  2. package/bundle/bundle.es7.js +26 -26
  3. package/bundle/bundle.lsp.js +27 -27
  4. package/bundle/bundle.min.js +26 -26
  5. package/config/.schema.json +6 -2
  6. package/data/.schema.json +7 -0
  7. package/data/ext/mapframe.json +4 -0
  8. package/data/ext/maplink.json +4 -0
  9. package/data/ext/templatedata.json +184 -0
  10. package/dist/addon/table.js +16 -10
  11. package/dist/addon/token.js +26 -32
  12. package/dist/addon/transclude.js +6 -3
  13. package/dist/base.d.mts +4 -2
  14. package/dist/base.d.ts +4 -2
  15. package/dist/base.js +2 -0
  16. package/dist/base.mjs +3 -1
  17. package/dist/index.d.ts +2 -2
  18. package/dist/index.js +33 -21
  19. package/dist/lib/document.d.ts +53 -0
  20. package/dist/lib/document.js +121 -0
  21. package/dist/lib/element.js +6 -3
  22. package/dist/lib/lsp.d.ts +5 -7
  23. package/dist/lib/lsp.js +154 -28
  24. package/dist/lib/node.js +19 -9
  25. package/dist/lib/text.js +4 -1
  26. package/dist/lib/title.js +9 -6
  27. package/dist/mixin/attributesParent.d.ts +8 -0
  28. package/dist/mixin/attributesParent.js +4 -0
  29. package/dist/parser/links.js +4 -1
  30. package/dist/parser/redirect.js +4 -1
  31. package/dist/src/arg.d.ts +2 -3
  32. package/dist/src/arg.js +16 -9
  33. package/dist/src/attribute.d.ts +12 -1
  34. package/dist/src/attribute.js +69 -1
  35. package/dist/src/attributes.d.ts +10 -3
  36. package/dist/src/attributes.js +15 -2
  37. package/dist/src/converter.d.ts +64 -5
  38. package/dist/src/converter.js +163 -131
  39. package/dist/src/converterFlags.d.ts +2 -3
  40. package/dist/src/converterFlags.js +5 -6
  41. package/dist/src/converterRule.js +4 -1
  42. package/dist/src/extLink.d.ts +19 -3
  43. package/dist/src/extLink.js +177 -194
  44. package/dist/src/gallery.js +7 -3
  45. package/dist/src/heading.d.ts +2 -3
  46. package/dist/src/heading.js +10 -5
  47. package/dist/src/html.d.ts +0 -3
  48. package/dist/src/html.js +90 -93
  49. package/dist/src/imageParameter.d.ts +2 -3
  50. package/dist/src/imageParameter.js +10 -4
  51. package/dist/src/imagemap.js +4 -1
  52. package/dist/src/imagemapLink.d.ts +2 -2
  53. package/dist/src/imagemapLink.js +5 -6
  54. package/dist/src/index.d.ts +6 -0
  55. package/dist/src/index.js +54 -4
  56. package/dist/src/link/base.js +8 -2
  57. package/dist/src/link/file.js +11 -2
  58. package/dist/src/link/galleryImage.d.ts +1 -0
  59. package/dist/src/link/galleryImage.js +15 -1
  60. package/dist/src/magicLink.js +4 -1
  61. package/dist/src/nested.d.ts +2 -3
  62. package/dist/src/nested.js +5 -2
  63. package/dist/src/nowiki/comment.js +4 -1
  64. package/dist/src/nowiki/doubleUnderscore.d.ts +2 -2
  65. package/dist/src/nowiki/doubleUnderscore.js +1 -2
  66. package/dist/src/nowiki/index.js +4 -1
  67. package/dist/src/nowiki/quote.js +4 -1
  68. package/dist/src/onlyinclude.js +4 -1
  69. package/dist/src/paramTag/index.js +5 -1
  70. package/dist/src/paramTag/inputbox.js +4 -1
  71. package/dist/src/parameter.js +4 -1
  72. package/dist/src/pre.js +4 -1
  73. package/dist/src/redirect.d.ts +2 -3
  74. package/dist/src/redirect.js +7 -6
  75. package/dist/src/table/base.js +4 -1
  76. package/dist/src/table/index.js +10 -3
  77. package/dist/src/table/td.d.ts +2 -2
  78. package/dist/src/table/td.js +5 -2
  79. package/dist/src/tagPair/ext.js +17 -5
  80. package/dist/src/tagPair/include.js +4 -1
  81. package/dist/src/tagPair/index.js +4 -1
  82. package/dist/src/transclude.d.ts +2 -3
  83. package/dist/src/transclude.js +20 -11
  84. package/dist/util/debug.js +1 -13
  85. package/dist/util/diff.js +20 -6
  86. package/dist/util/lint.js +4 -1
  87. package/dist/util/string.js +5 -2
  88. package/extensions/dist/base.js +29 -17
  89. package/extensions/dist/lint.js +1 -0
  90. package/extensions/dist/lsp.js +30 -22
  91. package/extensions/es7/base.js +29 -17
  92. package/extensions/es7/lint.js +1 -0
  93. package/extensions/typings.d.ts +9 -3
  94. package/package.json +12 -6
  95. package/dist/mixin/flagsParent.d.ts +0 -69
  96. package/dist/mixin/flagsParent.js +0 -64
  97. package/dist/mixin/magicLinkParent.d.ts +0 -25
  98. package/dist/mixin/magicLinkParent.js +0 -43
@@ -1,4 +1,5 @@
1
1
  {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
2
3
  "type": "object",
3
4
  "properties": {
4
5
  "ext": {
@@ -47,6 +48,7 @@
47
48
  "additionalProperties": false
48
49
  },
49
50
  "variable": {
51
+ "description": "canonical magic words as variables",
50
52
  "type": "array",
51
53
  "items": {
52
54
  "type": "string",
@@ -67,10 +69,11 @@
67
69
  "minItems": 2
68
70
  },
69
71
  "parserFunction": {
72
+ "description": "magic words as variables or parser functions",
70
73
  "type": "array",
71
74
  "prefixItems": [
72
75
  {
73
- "description": "case-insensitive parser functions",
76
+ "description": "case-insensitive variables or parser functions",
74
77
  "type": "object",
75
78
  "patternProperties": {
76
79
  "^[^A-Z]+$": {
@@ -81,7 +84,7 @@
81
84
  "additionalProperties": false
82
85
  },
83
86
  {
84
- "description": "case-sensitive parser functions",
87
+ "description": "case-sensitive variables or parser functions",
85
88
  "type": "object",
86
89
  "properties": {
87
90
  "!": {
@@ -163,6 +166,7 @@
163
166
  "pattern": "^[a-z:/]+(?:\\|[a-z:/]+)*$"
164
167
  },
165
168
  "interwiki": {
169
+ "description": "interwiki prefixes",
166
170
  "type": "array",
167
171
  "items": {
168
172
  "type": "string",
package/data/.schema.json CHANGED
@@ -1,4 +1,5 @@
1
1
  {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
2
3
  "type": "object",
3
4
  "additionalProperties": {
4
5
  "type": "array",
@@ -6,6 +7,7 @@
6
7
  "type": "object",
7
8
  "properties": {
8
9
  "aliases": {
10
+ "description": "An array of aliases for the magic word",
9
11
  "type": "array",
10
12
  "items": {
11
13
  "type": "string"
@@ -14,9 +16,11 @@
14
16
  "uniqueItems": true
15
17
  },
16
18
  "description": {
19
+ "description": "A brief description of the magic word",
17
20
  "type": "string"
18
21
  },
19
22
  "signatures": {
23
+ "description": "An array of signatures for the magic word",
20
24
  "type": "array",
21
25
  "items": {
22
26
  "type": "array",
@@ -24,12 +28,15 @@
24
28
  "type": "object",
25
29
  "properties": {
26
30
  "label": {
31
+ "description": "The label for the parameter",
27
32
  "type": "string"
28
33
  },
29
34
  "const": {
35
+ "description": "Whether the parameter is a constant",
30
36
  "type": "boolean"
31
37
  },
32
38
  "rest": {
39
+ "description": "Whether the parameter can repeat indefinitely",
33
40
  "type": "boolean"
34
41
  }
35
42
  },
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$ref": "https://geojson.org/schema/GeoJSON.json"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$ref": "https://geojson.org/schema/GeoJSON.json"
4
+ }
@@ -0,0 +1,184 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "definitions": {
4
+ "interfaceText": {
5
+ "oneOf": [
6
+ {
7
+ "type": "string"
8
+ },
9
+ {
10
+ "type": "object",
11
+ "minProperties": 1,
12
+ "additionalProperties": {
13
+ "type": "string"
14
+ }
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ "type": "object",
20
+ "properties": {
21
+ "description": {
22
+ "markdownDescription": "A brief description of the template. **It must be in plain text.** Once filled, it can be displayed as caption when editing a single template and perhaps in search results when users pick one of many. The default is `null`.",
23
+ "oneOf": [
24
+ {
25
+ "$ref": "#/definitions/interfaceText"
26
+ },
27
+ {
28
+ "type": "null"
29
+ }
30
+ ]
31
+ },
32
+ "params": {
33
+ "markdownDescription": "An object that maps each parameter name of the template to a corresponding [Param object](https://www.mediawiki.org/wiki/Extension:TemplateData#Param_object) describing the properties of that parameter.",
34
+ "type": "object",
35
+ "additionalProperties": {
36
+ "type": "object",
37
+ "properties": {
38
+ "label": {
39
+ "markdownDescription": "A (very) brief name for the parameter. Try to keep under 20-ish characters.",
40
+ "$ref": "#/definitions/interfaceText"
41
+ },
42
+ "description": {
43
+ "markdownDescription": "A brief description of the parameter, for users to know which to pick from an option list.",
44
+ "$ref": "#/definitions/interfaceText"
45
+ },
46
+ "required": {
47
+ "markdownDescription": "Whether the parameter is required for the template to work (true if this parameter **must** be specified).",
48
+ "type": "boolean"
49
+ },
50
+ "suggested": {
51
+ "markdownDescription": "Whether the parameter is suggested for the template to be useful (true if this parameter **should** be specified).",
52
+ "type": "boolean"
53
+ },
54
+ "deprecated": {
55
+ "markdownDescription": "Whether the parameter is deprecated. The value can be a string of instructions giving the user guidance what instead can be done, or be simply `true`.",
56
+ "oneOf": [
57
+ {
58
+ "type": "string"
59
+ },
60
+ {
61
+ "type": "boolean"
62
+ }
63
+ ]
64
+ },
65
+ "aliases": {
66
+ "markdownDescription": "List of aliases. An alias is an alternative name for the parameter that may be used instead of (not in addition to) the primary name. Aliases are not documented in a separate Parameter object. If they need more information, they should be in their own property marked \"deprecated\".",
67
+ "type": "array",
68
+ "items": {
69
+ "type": "string"
70
+ }
71
+ },
72
+ "default": {
73
+ "markdownDescription": "A fixed default value used by the template if no value is assigned to the parameter, or a description thereof.",
74
+ "$ref": "#/definitions/interfaceText"
75
+ },
76
+ "autovalue": {
77
+ "markdownDescription": "A dynamically-generated default value in wikitext, such as today's date or the editing user's name; this will often involve wikitext substitution, such as `{{subst:CURRENTYEAR}}`.",
78
+ "type": "string"
79
+ },
80
+ "example": {
81
+ "markdownDescription": "An example text for the parameter, to help users fill in the proper value.",
82
+ "$ref": "#/definitions/interfaceText"
83
+ },
84
+ "type": {
85
+ "markdownDescription": "The type of the parameter, for (soft) type hinting.",
86
+ "type": "string",
87
+ "enum": [
88
+ "unknown",
89
+ "number",
90
+ "string",
91
+ "line",
92
+ "boolean",
93
+ "date",
94
+ "url",
95
+ "wiki-page-name",
96
+ "wiki-file-name",
97
+ "wiki-template-name",
98
+ "wiki-user-name",
99
+ "content",
100
+ "unbalanced-wikitext"
101
+ ]
102
+ },
103
+ "inherits": {
104
+ "markdownDescription": "The name key of another parameter (must be a valid key in the `params` object). The current [Parameter Object](https://www.mediawiki.org/wiki/Extension:TemplateData#Param_object) will inherit properties from the specified [Parameter Object](https://www.mediawiki.org/wiki/Extension:TemplateData#Param_object), with local properties overriding the inherited ones.",
105
+ "type": "string"
106
+ },
107
+ "suggestedValues": {
108
+ "markdownDescription": "An optional parameter property. Creates a list of parameter values to help users select the desired value. For the suggested values to be displayed as a combo box in VisualEditor, the parameter’s type must be set to one of the following: content, line, string, number, unknown or unbalanced wikitext.",
109
+ "type": "array",
110
+ "items": {
111
+ "type": "string"
112
+ }
113
+ }
114
+ },
115
+ "additionalProperties": false
116
+ }
117
+ },
118
+ "paramOrder": {
119
+ "markdownDescription": "The logical order in which parameters should be displayed. The array contains each parameter key exactly once. Each string must be a valid key in the `params` object.",
120
+ "type": "array",
121
+ "items": {
122
+ "type": "string"
123
+ }
124
+ },
125
+ "sets": {
126
+ "markdownDescription": "An array containing set specifications. A set is a group of parameters that should be used together. The default is []. Note that the `sets` functionality is still in development.",
127
+ "type": "array",
128
+ "items": {
129
+ "type": "object",
130
+ "properties": {
131
+ "label": {
132
+ "markdownDescription": "A (very) brief name for the parameter. Try to keep under 20-ish characters.",
133
+ "$ref": "#/definitions/interfaceText"
134
+ },
135
+ "params": {
136
+ "markdownDescription": "One or more names of parameters to include in the set (each must be a valid key in the `params` object). A parameter may be in multiple sets. Not every parameter must be in a set.",
137
+ "type": "array",
138
+ "items": {
139
+ "type": "string"
140
+ }
141
+ }
142
+ },
143
+ "additionalProperties": false
144
+ }
145
+ },
146
+ "format": {
147
+ "markdownDescription": "How the template's wikitext representation SHOULD be laid out. The default is `inline`. See [custom formats](https://www.mediawiki.org/wiki/Special:MyLanguage/Help:TemplateData#Custom_formats) for other custom formats.",
148
+ "type": "string"
149
+ },
150
+ "maps": {
151
+ "markdownDescription": "An object that links a simplified name of a third party consumer of the template data (i.e. [Citoid](https://www.mediawiki.org/wiki/Citoid), [Special:MyLanguage/Wikidata](https://www.mediawiki.org/wiki/Special:MyLanguage/Wikidata), etc.) to a map object that in turn links a name of a consumer parameter to one or more corresponding names of template parameters.",
152
+ "type": "object",
153
+ "additionalProperties": {
154
+ "type": "object",
155
+ "additionalProperties": {
156
+ "oneOf": [
157
+ {
158
+ "type": "string"
159
+ },
160
+ {
161
+ "type": "array",
162
+ "items": {
163
+ "type": "string"
164
+ }
165
+ },
166
+ {
167
+ "type": "array",
168
+ "items": {
169
+ "type": "array",
170
+ "items": {
171
+ "type": "string"
172
+ }
173
+ }
174
+ }
175
+ ]
176
+ }
177
+ }
178
+ }
179
+ },
180
+ "required": [
181
+ "params"
182
+ ],
183
+ "additionalProperties": false
184
+ }
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  /* eslint @stylistic/operator-linebreak: [2, "before", {overrides: {"=": "after"}}] */
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
3
6
  Object.defineProperty(exports, "__esModule", { value: true });
4
- const assert = require("assert/strict");
7
+ const strict_1 = __importDefault(require("assert/strict"));
5
8
  const debug_1 = require("../util/debug");
6
9
  const constants_1 = require("../util/constants");
7
10
  const index_1 = require("../src/index");
@@ -106,7 +109,10 @@ index_2.TableToken.prototype.toRawCoords =
106
109
  function ({ x, y }) {
107
110
  const rowLayout = this.getLayout({ x, y })[y], coords = rowLayout?.[x];
108
111
  if (coords) {
109
- return { ...coords, start: coords.row === y && rowLayout[x - 1] !== coords };
112
+ return {
113
+ ...coords,
114
+ start: coords.row === y && rowLayout[x - 1] !== coords,
115
+ };
110
116
  }
111
117
  else if (rowLayout || y > 0) {
112
118
  return x === rowLayout?.length
@@ -223,8 +229,8 @@ index_2.TableToken.prototype.insertTableCol =
223
229
  throw new RangeError(`Row ${rowLength.indexOf(minCol)} has only ${minCol} column(s)!`);
224
230
  }
225
231
  const token = (0, td_1.createTd)(inner, subtype, attr, this.getAttribute('include'), this.getAttribute('config'));
226
- for (const [i, rowLayout] of layout.entries()) {
227
- const coords = rowLayout[x], prevCoords = x === 0 ? true : rowLayout[x - 1];
232
+ for (let i = 0; i < layout.length; i++) {
233
+ const rowLayout = layout[i], coords = rowLayout[x], prevCoords = x === 0 ? true : rowLayout[x - 1];
228
234
  if (!prevCoords) {
229
235
  continue;
230
236
  }
@@ -398,10 +404,10 @@ index_2.TableToken.prototype.moveTableRowBefore =
398
404
  function (y, before) {
399
405
  const layout = this.getLayout();
400
406
  try {
401
- assert.deepEqual(occupied(layout, y), occupied(layout, before));
407
+ strict_1.default.deepEqual(occupied(layout, y), occupied(layout, before));
402
408
  }
403
409
  catch (e) {
404
- if (e instanceof assert.AssertionError) {
410
+ if (e instanceof strict_1.default.AssertionError) {
405
411
  throw new RangeError(`The structure of row ${y} is different from that of row ${before}, so it cannot be moved!`);
406
412
  }
407
413
  throw e;
@@ -424,10 +430,10 @@ index_2.TableToken.prototype.moveTableRowAfter =
424
430
  function (y, after) {
425
431
  const layout = this.getLayout(), afterToken = this.getNthRow(after), cells = afterToken.childNodes.filter(child => child.type === 'td' && child.subtype !== 'caption');
426
432
  try {
427
- assert.deepEqual(occupied(layout, y), occupied(layout, after, true, cells));
433
+ strict_1.default.deepEqual(occupied(layout, y), occupied(layout, after, true, cells));
428
434
  }
429
435
  catch (e) {
430
- if (e instanceof assert.AssertionError) {
436
+ if (e instanceof strict_1.default.AssertionError) {
431
437
  throw new RangeError(`The structure of row ${y} is different from that of row ${after}, so it cannot be moved!`);
432
438
  }
433
439
  throw e;
@@ -461,8 +467,8 @@ index_2.TableToken.prototype.moveCol =
461
467
  throw new RangeError(`The structure of column ${x} is different from that of column ${reference}, so it cannot be moved!`);
462
468
  }
463
469
  const setX = new WeakSet(), setRef = new WeakSet(), rows = this.getAllRows();
464
- for (const [i, rowLayout] of layout.entries()) {
465
- const coords = rowLayout[x], refCoords = rowLayout[reference], start = isStartCol(rowLayout, x);
470
+ for (let i = 0; i < layout.length; i++) {
471
+ const rowLayout = layout[i], coords = rowLayout[x], refCoords = rowLayout[reference], start = isStartCol(rowLayout, x);
466
472
  if (refCoords && !start && !setRef.has(refCoords)) {
467
473
  setRef.add(refCoords);
468
474
  rows[refCoords.row].getNthCol(refCoords.column).colspan++;
@@ -1,11 +1,14 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const fs = require("fs");
4
- const path = require("path");
6
+ const fs_1 = __importDefault(require("fs"));
7
+ const path_1 = __importDefault(require("path"));
5
8
  const constants_1 = require("../util/constants");
6
9
  const debug_1 = require("../util/debug");
7
10
  const string_1 = require("../util/string");
8
- const index_1 = require("../index");
11
+ const index_1 = __importDefault(require("../index"));
9
12
  const index_2 = require("../src/index");
10
13
  const comment_1 = require("../src/nowiki/comment");
11
14
  const include_1 = require("../src/tagPair/include");
@@ -96,17 +99,17 @@ const expand = (wikitext, config, include, context, accum = [], stack = []) => {
96
99
  if (index_1.default.templateDir === undefined) {
97
100
  return m;
98
101
  }
99
- else if (!path.isAbsolute(index_1.default.templateDir)) {
100
- index_1.default.templateDir = path.join(__dirname, '..', '..', index_1.default.templateDir);
102
+ else if (!path_1.default.isAbsolute(index_1.default.templateDir)) {
103
+ index_1.default.templateDir = path_1.default.join(__dirname, '..', '..', index_1.default.templateDir);
101
104
  }
102
105
  const titles = [title, title.replaceAll('_', ' ')]
103
106
  .flatMap(tt => [tt, tt.replaceAll(':', '꞉')]), file = ['.wiki', '.txt', '']
104
- .flatMap(ext => titles.map(tt => path.join(index_1.default.templateDir, tt + ext)))
105
- .find(fs.existsSync);
107
+ .flatMap(ext => titles.map(tt => path_1.default.join(index_1.default.templateDir, tt + ext)))
108
+ .find(fs_1.default.existsSync);
106
109
  if (!file) {
107
110
  return m;
108
111
  }
109
- index_1.default.templates.set(title, fs.readFileSync(file, 'utf8'));
112
+ index_1.default.templates.set(title, fs_1.default.readFileSync(file, 'utf8'));
110
113
  }
111
114
  else if (stack.includes(title)) {
112
115
  return `${prev}<span class="error">Template loop detected: [[${title}]]</span>`;
@@ -314,7 +317,8 @@ index_2.Token.prototype.sections = /** @implements */ function () {
314
317
  range.setStart(this, i);
315
318
  return range;
316
319
  });
317
- for (const [i, [index, level]] of headings.entries()) {
320
+ for (let i = 0; i < headings.length; i++) {
321
+ const [index, level] = headings[i];
318
322
  for (let j = level; j < 6; j++) {
319
323
  const last = lastHeading[j];
320
324
  if (last >= 0) {
@@ -338,40 +342,30 @@ index_2.Token.prototype.findEnclosingHtml = /** @implements */ function (tag) {
338
342
  tag &&= tag.toLowerCase();
339
343
  const { html } = this.getAttribute('config'), normalTags = new Set(html[0]), voidTags = new Set(html[2]);
340
344
  /* istanbul ignore next */
341
- if (html[2].includes(tag)) {
345
+ if (voidTags.has(tag)) {
342
346
  throw new RangeError(`Void tag: ${tag}`);
343
347
  }
344
- else if (tag !== undefined && !html.slice(0, 2).some(tags => tags.includes(tag))) {
348
+ else if (tag && !normalTags.has(tag) && !html[1].includes(tag)) {
345
349
  throw new RangeError(`Invalid tag name: ${tag}`);
346
350
  }
347
351
  const { parentNode } = this;
348
352
  if (!parentNode) {
349
353
  return undefined;
350
354
  }
351
- /**
352
- * 检查是否为指定的 HTML 标签
353
- * @param node 节点
354
- * @param name 标签名
355
- * @param closing 是否为闭合标签
356
- */
357
- const checkHtml = (node, name, closing) => node.is('html')
358
- && (!name && !voidTags.has(node.name) || node.name === name)
359
- && (normalTags.has(node.name) || !node.selfClosing)
360
- && node.closing === closing;
361
- const { childNodes, length } = parentNode, index = childNodes.indexOf(this);
362
- let i = index - 1, j = length;
355
+ const { childNodes } = parentNode, index = childNodes.indexOf(this);
356
+ let i = index - 1, j;
363
357
  for (; i >= 0; i--) {
364
- const open = childNodes[i];
365
- if (checkHtml(open, tag, false)) {
366
- for (j = index + 1; j < length; j++) {
367
- const close = childNodes[j];
368
- if (checkHtml(close, open.name, true)) {
358
+ const open = childNodes[i], { name, closing, selfClosing } = open;
359
+ if (open.is('html') && !closing
360
+ && (tag ? name === tag : !voidTags.has(name))
361
+ && (normalTags.has(name) || !selfClosing)) {
362
+ const close = open.findMatchingTag();
363
+ if (close) {
364
+ j = childNodes.indexOf(close);
365
+ if (j > index) {
369
366
  break;
370
367
  }
371
368
  }
372
- if (j < length) {
373
- break;
374
- }
375
369
  }
376
370
  }
377
371
  if (i === -1) {
@@ -379,7 +373,7 @@ index_2.Token.prototype.findEnclosingHtml = /** @implements */ function (tag) {
379
373
  }
380
374
  const range = this.createRange();
381
375
  range.setStart(parentNode, i);
382
- range.setEnd(parentNode, j + 1);
376
+ range.setEnd(parentNode, j + 1); // eslint-disable-line @typescript-eslint/no-unnecessary-type-assertion
383
377
  return range;
384
378
  };
385
379
  constants_1.classes['ExtendedToken'] = __filename;
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
  /* eslint @stylistic/operator-linebreak: [2, "before", {overrides: {"=": "after"}}] */
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
3
6
  Object.defineProperty(exports, "__esModule", { value: true });
4
7
  const constants_1 = require("../util/constants");
5
8
  const debug_1 = require("../util/debug");
6
9
  const string_1 = require("../util/string");
7
- const index_1 = require("../index");
10
+ const index_1 = __importDefault(require("../index"));
8
11
  const index_2 = require("../src/index");
9
12
  const transclude_1 = require("../src/transclude");
10
13
  const parameter_1 = require("../src/parameter");
@@ -142,8 +145,8 @@ transclude_1.TranscludeToken.prototype.fixDuplication =
142
145
  return cmp;
143
146
  });
144
147
  if (ordered) {
145
- for (const [i, arg] of series.entries()) {
146
- const name = `${str}${i + 1}`;
148
+ for (let i = 0; i < series.length; i++) {
149
+ const arg = series[i], name = `${str}${i + 1}`;
147
150
  if (arg.name !== name) {
148
151
  if (arg.name === key) {
149
152
  remaining--;
package/dist/base.d.mts CHANGED
@@ -44,7 +44,7 @@ export declare const stages: {
44
44
  converter: number;
45
45
  };
46
46
  export type Stage = keyof typeof stages;
47
- 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"];
47
+ 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
48
  export declare namespace LintError {
49
49
  type Severity = 'error' | 'warning';
50
50
  type Rule = typeof rules[number];
@@ -66,6 +66,7 @@ export interface LintError {
66
66
  endCol: number;
67
67
  fix?: LintError.Fix;
68
68
  suggestions?: LintError.Fix[];
69
+ code?: string;
69
70
  }
70
71
  export type AST = Record<string, string | number | boolean> & {
71
72
  range: [number, number];
@@ -139,9 +140,10 @@ export interface SignatureData {
139
140
  parserFunctions: SignatureInfo[];
140
141
  }
141
142
  export type CompletionItem = Omit<CompletionItemBase, 'kind'> & {
142
- kind: keyof typeof CompletionItemKind;
143
+ kind?: CompletionItemKind | keyof typeof CompletionItemKind;
143
144
  };
144
145
  export interface LanguageService {
146
+ include: boolean;
145
147
  /**
146
148
  * Destroy the instance
147
149
  *
package/dist/base.d.ts CHANGED
@@ -44,7 +44,7 @@ export declare const stages: {
44
44
  converter: number;
45
45
  };
46
46
  export type Stage = keyof typeof stages;
47
- 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"];
47
+ 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
48
  export declare namespace LintError {
49
49
  type Severity = 'error' | 'warning';
50
50
  type Rule = typeof rules[number];
@@ -66,6 +66,7 @@ export interface LintError {
66
66
  endCol: number;
67
67
  fix?: LintError.Fix;
68
68
  suggestions?: LintError.Fix[];
69
+ code?: string;
69
70
  }
70
71
  export type AST = Record<string, string | number | boolean> & {
71
72
  range: [number, number];
@@ -139,9 +140,10 @@ export interface SignatureData {
139
140
  parserFunctions: SignatureInfo[];
140
141
  }
141
142
  export type CompletionItem = Omit<CompletionItemBase, 'kind'> & {
142
- kind: keyof typeof CompletionItemKind;
143
+ kind?: CompletionItemKind | keyof typeof CompletionItemKind;
143
144
  };
144
145
  export interface LanguageService {
146
+ include: boolean;
145
147
  /**
146
148
  * Destroy the instance
147
149
  *
package/dist/base.js CHANGED
@@ -67,6 +67,8 @@ exports.rules = (() => {
67
67
  'url-encoding',
68
68
  'var-anchor',
69
69
  'void-ext',
70
+ /* NOT FOR BROWSER ONLY */
71
+ 'invalid-css',
70
72
  ];
71
73
  Object.freeze(arr);
72
74
  return arr;
package/dist/base.mjs CHANGED
@@ -63,7 +63,9 @@ const rules = /* @__PURE__ */ (() => {
63
63
  "unterminated-url",
64
64
  "url-encoding",
65
65
  "var-anchor",
66
- "void-ext"
66
+ "void-ext",
67
+ /* NOT FOR BROWSER ONLY */
68
+ "invalid-css"
67
69
  ];
68
70
  Object.freeze(arr);
69
71
  return arr;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Config, LintError, TokenTypes, Parser as ParserBase, Stage, AST } from './base';
2
2
  import type { Title } from './lib/title';
3
- import type { LanguageService } from './lib/lsp';
3
+ import type { LanguageService, QuickFixData } from './lib/lsp';
4
4
  import type { Token } from './internal';
5
5
  declare interface Parser extends ParserBase {
6
6
  rules: readonly LintError.Rule[];
@@ -39,6 +39,6 @@ declare const Parser: Parser;
39
39
  // @ts-expect-error mixed export styles
40
40
  export = Parser;
41
41
  export default Parser;
42
- export type { Config, LintError, TokenTypes, LanguageService, AST, };
42
+ export type { Config, LintError, TokenTypes, LanguageService, QuickFixData, AST, };
43
43
  export type * from './internal';
44
44
  declare global { type Acceptable = unknown; }