wikiparser-node 1.25.0 → 1.26.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 (66) hide show
  1. package/README.md +2 -2
  2. package/bundle/bundle-es8.min.js +25 -24
  3. package/bundle/bundle-lsp.min.js +31 -30
  4. package/bundle/bundle.min.js +25 -25
  5. package/config/default.json +3 -0
  6. package/config/enwiki.json +3 -0
  7. package/config/jawiki.json +3 -0
  8. package/config/minimum.json +1 -0
  9. package/config/moegirl.json +0 -20
  10. package/config/zhwiki.json +3 -0
  11. package/data/ext/math.json +41 -0
  12. package/dist/addon/token.js +1 -1
  13. package/dist/base.d.mts +17 -4
  14. package/dist/base.d.ts +17 -4
  15. package/dist/bin/config.js +8 -2
  16. package/dist/index.d.ts +5 -3
  17. package/dist/index.js +74 -53
  18. package/dist/lib/element.js +34 -30
  19. package/dist/lib/lintConfig.d.ts +18 -7
  20. package/dist/lib/lintConfig.js +55 -15
  21. package/dist/lib/lsp.js +16 -8
  22. package/dist/lib/text.js +176 -171
  23. package/dist/mixin/hidden.js +1 -1
  24. package/dist/mixin/noEscape.js +9 -7
  25. package/dist/parser/links.js +10 -4
  26. package/dist/src/arg.js +41 -33
  27. package/dist/src/attribute.js +63 -39
  28. package/dist/src/attributes.js +62 -51
  29. package/dist/src/commented.js +2 -1
  30. package/dist/src/converterFlags.js +22 -18
  31. package/dist/src/converterRule.js +6 -3
  32. package/dist/src/extLink.js +6 -4
  33. package/dist/src/gallery.js +50 -42
  34. package/dist/src/heading.js +75 -61
  35. package/dist/src/html.js +85 -72
  36. package/dist/src/imageParameter.js +21 -15
  37. package/dist/src/imagemap.js +22 -18
  38. package/dist/src/index.js +107 -97
  39. package/dist/src/link/base.js +46 -33
  40. package/dist/src/link/category.js +11 -6
  41. package/dist/src/link/file.js +93 -77
  42. package/dist/src/link/galleryImage.js +10 -6
  43. package/dist/src/link/index.js +10 -6
  44. package/dist/src/link/redirectTarget.js +12 -8
  45. package/dist/src/magicLink.js +25 -20
  46. package/dist/src/nested.js +31 -27
  47. package/dist/src/nowiki/comment.js +13 -9
  48. package/dist/src/nowiki/index.js +11 -7
  49. package/dist/src/nowiki/listBase.js +8 -5
  50. package/dist/src/nowiki/quote.js +33 -25
  51. package/dist/src/paramTag/index.js +26 -22
  52. package/dist/src/parameter.js +31 -23
  53. package/dist/src/pre.js +1 -1
  54. package/dist/src/redirect.js +5 -3
  55. package/dist/src/syntax.js +1 -1
  56. package/dist/src/table/index.js +35 -31
  57. package/dist/src/table/td.js +26 -19
  58. package/dist/src/table/trBase.js +13 -11
  59. package/dist/src/tagPair/ext.js +13 -10
  60. package/dist/src/tagPair/include.js +17 -11
  61. package/dist/src/transclude.js +45 -37
  62. package/dist/util/constants.js +2 -1
  63. package/dist/util/lint.js +2 -1
  64. package/extensions/dist/base.js +1 -1
  65. package/extensions/editor.css +2 -2
  66. package/package.json +6 -6
@@ -54,15 +54,19 @@ class RedirectTargetToken extends base_1.LinkBaseToken {
54
54
  }
55
55
  /** @private */
56
56
  lint(start = this.getAbsoluteIndex()) {
57
- const errors = super.lint(start, false), rule = 'no-ignored', s = index_1.default.lintConfig.getSeverity(rule, 'redirect');
58
- if (s && this.length === 2) {
59
- const e = (0, lint_1.generateForChild)(this.lastChild, { start }, rule, 'useless-link-text', s);
60
- e.startIndex--;
61
- e.startCol--;
62
- e.fix = (0, lint_1.fixByRemove)(e);
63
- errors.push(e);
57
+ LINT: { // eslint-disable-line no-unused-labels
58
+ const errors = super.lint(start, false), rule = 'no-ignored', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, 'redirect');
59
+ if (s && this.length === 2) {
60
+ const e = (0, lint_1.generateForChild)(this.lastChild, { start }, rule, 'useless-link-text', s);
61
+ e.startIndex--;
62
+ e.startCol--;
63
+ if (lintConfig.computeEditInfo || lintConfig.fix) {
64
+ e.fix = (0, lint_1.fixByRemove)(e);
65
+ }
66
+ errors.push(e);
67
+ }
68
+ return errors;
64
69
  }
65
- return errors;
66
70
  }
67
71
  /* NOT FOR BROWSER */
68
72
  /** @private */
@@ -179,29 +179,34 @@ let MagicLinkToken = (() => {
179
179
  }
180
180
  /** @private */
181
181
  lint(start = this.getAbsoluteIndex(), re) {
182
- const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start), { type, childNodes } = this;
183
- if (type === 'magic-link') {
184
- const rule = 'invalid-isbn', s = index_1.default.lintConfig.getSeverity(rule);
185
- if (s && this.#lint()) {
186
- errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'invalid-isbn', s));
182
+ LINT: { // eslint-disable-line no-unused-labels
183
+ const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start), { lintConfig } = index_1.default, { type, childNodes } = this;
184
+ if (type === 'magic-link') {
185
+ const rule = 'invalid-isbn', s = lintConfig.getSeverity(rule);
186
+ if (s && this.#lint()) {
187
+ errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'invalid-isbn', s));
188
+ }
189
+ return errors;
187
190
  }
188
- return errors;
189
- }
190
- const pipe = type === 'ext-link-url', rule = 'unterminated-url', severity = index_1.default.lintConfig.getSeverity(rule, pipe ? 'pipe' : 'punctuation');
191
- if (severity) {
192
- const regex = pipe ? /\|/u : /[,;。:!?()]+/u, child = childNodes.find((c) => c.type === 'text' && regex.test(c.data));
193
- if (child) {
194
- const { data } = child, e = (0, lint_1.generateForChild)(child, rect, rule, index_1.default.msg('in-url', pipe ? '"|"' : 'full-width-punctuation'), severity), { index, 0: s } = regex.exec(data), i = e.startIndex + index;
195
- e.suggestions = pipe
196
- ? [(0, lint_1.fixBySpace)(i, 1)]
197
- : [
198
- (0, lint_1.fixBySpace)(i),
199
- { desc: index_1.default.msg('encode'), range: [i, i + s.length], text: encodeURI(s) },
200
- ];
201
- errors.push(e);
191
+ const pipe = type === 'ext-link-url', rule = 'unterminated-url', severity = lintConfig.getSeverity(rule, pipe ? 'pipe' : 'punctuation');
192
+ if (severity) {
193
+ const regex = pipe ? /\|/u : /[,;。:!?()]+/u, child = childNodes.find((c) => c.type === 'text' && regex.test(c.data));
194
+ if (child) {
195
+ const { data } = child, e = (0, lint_1.generateForChild)(child, rect, rule, index_1.default.msg('in-url', pipe ? '"|"' : 'full-width-punctuation'), severity);
196
+ if (lintConfig.computeEditInfo) {
197
+ const { index, 0: s } = regex.exec(data), i = e.startIndex + index;
198
+ e.suggestions = pipe
199
+ ? [(0, lint_1.fixBySpace)(i, 1)]
200
+ : [
201
+ (0, lint_1.fixBySpace)(i),
202
+ { desc: index_1.default.msg('encode'), range: [i, i + s.length], text: encodeURI(s) },
203
+ ];
204
+ }
205
+ errors.push(e);
206
+ }
202
207
  }
208
+ return errors;
203
209
  }
204
- return errors;
205
210
  }
206
211
  /**
207
212
  * Get the URL
@@ -50,12 +50,12 @@ const noinclude_1 = require("./nowiki/noinclude");
50
50
  const debug_1 = require("../util/debug");
51
51
  const constants_1 = require("../util/constants");
52
52
  const clone_1 = require("../mixin/clone");
53
- const childTypes = new Set(['comment', 'include', 'arg', 'template', 'magic-word']), lintRegex = [false, true].map(article => {
53
+ const childTypes = new Set(['comment', 'include', 'arg', 'template', 'magic-word']), lintRegex = /* #__PURE__ */ (() => [false, true].map(article => {
54
54
  const noinclude = article ? 'includeonly' : 'noinclude';
55
55
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
56
56
  /^(?:<noinclude(?:\s[^>]*)?\/?>|<\/noinclude\s*>)$/iu;
57
57
  return new RegExp(String.raw `^(?:<${noinclude}(?:\s[^>]*)?/?>|</${noinclude}\s*>)$`, 'iu');
58
- });
58
+ }))();
59
59
  /**
60
60
  * extension tag that has a nested structure
61
61
  *
@@ -110,32 +110,36 @@ let NestedToken = (() => {
110
110
  }
111
111
  /** @private */
112
112
  lint(start = this.getAbsoluteIndex(), re) {
113
- const errors = super.lint(start, re), rule = 'no-ignored', s = index_1.default.lintConfig.getSeverity(rule, this.name);
114
- if (!s) {
115
- return errors;
113
+ LINT: { // eslint-disable-line no-unused-labels
114
+ const errors = super.lint(start, re), rule = 'no-ignored', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, this.name);
115
+ if (!s) {
116
+ return errors;
117
+ }
118
+ const rect = new rect_1.BoundingRect(this, start), regex = typeof this.#regex === 'boolean' ? lintRegex[this.#regex ? 1 : 0] : /^<!--[\s\S]*-->$/u;
119
+ return [
120
+ ...errors,
121
+ ...this.childNodes.filter(child => {
122
+ const { type, name } = child;
123
+ if (type === 'ext') {
124
+ return !this.#tags.includes(name);
125
+ }
126
+ else if (childTypes.has(type)) {
127
+ return false;
128
+ }
129
+ const str = child.toString().trim();
130
+ return str && !regex.test(str);
131
+ }).map(child => {
132
+ const e = (0, lint_1.generateForChild)(child, rect, rule, index_1.default.msg('invalid-content', this.name), s);
133
+ if (lintConfig.computeEditInfo) {
134
+ e.suggestions = [
135
+ (0, lint_1.fixByRemove)(e),
136
+ (0, lint_1.fixByComment)(e, child.toString()),
137
+ ];
138
+ }
139
+ return e;
140
+ }),
141
+ ];
116
142
  }
117
- const rect = new rect_1.BoundingRect(this, start), regex = typeof this.#regex === 'boolean' ? lintRegex[this.#regex ? 1 : 0] : /^<!--[\s\S]*-->$/u;
118
- return [
119
- ...errors,
120
- ...this.childNodes.filter(child => {
121
- const { type, name } = child;
122
- if (type === 'ext') {
123
- return !this.#tags.includes(name);
124
- }
125
- else if (childTypes.has(type)) {
126
- return false;
127
- }
128
- const str = child.toString().trim();
129
- return str && !regex.test(str);
130
- }).map(child => {
131
- const e = (0, lint_1.generateForChild)(child, rect, rule, index_1.default.msg('invalid-content', this.name), s);
132
- e.suggestions = [
133
- (0, lint_1.fixByRemove)(e),
134
- (0, lint_1.fixByComment)(e, child.toString()),
135
- ];
136
- return e;
137
- }),
138
- ];
139
143
  }
140
144
  /* NOT FOR BROWSER */
141
145
  /**
@@ -87,16 +87,20 @@ let CommentToken = (() => {
87
87
  }
88
88
  /** @private */
89
89
  lint(start = this.getAbsoluteIndex()) {
90
- if (this.closed) {
91
- return [];
90
+ LINT: { // eslint-disable-line no-unused-labels
91
+ if (this.closed) {
92
+ return [];
93
+ }
94
+ const rule = 'unclosed-comment', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule);
95
+ if (!s) {
96
+ return [];
97
+ }
98
+ const e = (0, lint_1.generateForSelf)(this, { start }, rule, index_1.default.msg('unclosed', 'html-comment'), s);
99
+ if (lintConfig.computeEditInfo) {
100
+ e.suggestions = [(0, lint_1.fixByClose)(e.endIndex, '-->')];
101
+ }
102
+ return [e];
92
103
  }
93
- const rule = 'unclosed-comment', s = index_1.default.lintConfig.getSeverity(rule);
94
- if (!s) {
95
- return [];
96
- }
97
- const e = (0, lint_1.generateForSelf)(this, { start }, rule, index_1.default.msg('unclosed', 'html-comment'), s);
98
- e.suggestions = [(0, lint_1.fixByClose)(e.endIndex, '-->')];
99
- return [e];
100
104
  }
101
105
  /** @private */
102
106
  toString(skip) {
@@ -12,7 +12,7 @@ const base_1 = require("./base");
12
12
  const constants_1 = require("../../util/constants");
13
13
  /* NOT FOR BROWSER END */
14
14
  /<\s*(?:\/\s*)?(nowiki)\b/giu; // eslint-disable-line @typescript-eslint/no-unused-expressions
15
- const getLintRegex = (0, common_1.getRegex)(name => new RegExp(String.raw `<\s*(?:/\s*)${name === 'nowiki' ? '' : '?'}(${name})\b`, 'giu'));
15
+ const getLintRegex = /* #__PURE__ */ (0, common_1.getRegex)(name => new RegExp(String.raw `<\s*(?:/\s*)${name === 'nowiki' ? '' : '?'}(${name})\b`, 'giu'));
16
16
  const voidExt = new Set(['languages', 'section', 'templatestyles']);
17
17
  /**
18
18
  * text-only token inside an extension tag
@@ -31,13 +31,17 @@ class NowikiToken extends base_1.NowikiBaseToken {
31
31
  }
32
32
  /** @private */
33
33
  lint(start = this.getAbsoluteIndex()) {
34
- const { name } = this, rule = 'void-ext', s = index_1.default.lintConfig.getSeverity(rule, name);
35
- if (s && this.#lint()) {
36
- const e = (0, lint_1.generateForSelf)(this, { start }, rule, index_1.default.msg('nothing-in', name), s);
37
- e.suggestions = [(0, lint_1.fixByRemove)(e)];
38
- return [e];
34
+ LINT: { // eslint-disable-line no-unused-labels
35
+ const { name } = this, rule = 'void-ext', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, name);
36
+ if (s && this.#lint()) {
37
+ const e = (0, lint_1.generateForSelf)(this, { start }, rule, index_1.default.msg('nothing-in', name), s);
38
+ if (lintConfig.computeEditInfo) {
39
+ e.suggestions = [(0, lint_1.fixByRemove)(e)];
40
+ }
41
+ return [e];
42
+ }
43
+ return super.lint(start, getLintRegex(name));
39
44
  }
40
- return super.lint(start, getLintRegex(name));
41
45
  }
42
46
  /* PRINT ONLY */
43
47
  /** @private */
@@ -17,7 +17,7 @@ class ListBaseToken extends base_1.NowikiBaseToken {
17
17
  * @since v1.16.5
18
18
  */
19
19
  get indent() {
20
- return this.innerText.split(':').length - 1;
20
+ LSP: return this.innerText.split(':').length - 1; // eslint-disable-line no-unused-labels
21
21
  }
22
22
  /* PRINT ONLY END */
23
23
  /* NOT FOR BROWSER */
@@ -47,11 +47,14 @@ class ListBaseToken extends base_1.NowikiBaseToken {
47
47
  /* NOT FOR BROWSER END */
48
48
  /** @private */
49
49
  json(_, start = this.getAbsoluteIndex()) {
50
- const json = super.json(undefined, start), { indent } = this;
51
- if (indent) {
52
- json['indent'] = indent;
50
+ const json = super.json(undefined, start);
51
+ LSP: { // eslint-disable-line no-unused-labels
52
+ const { indent } = this;
53
+ if (indent) {
54
+ json['indent'] = indent;
55
+ }
56
+ return json;
53
57
  }
54
- return json;
55
58
  }
56
59
  /* NOT FOR BROWSER */
57
60
  /**
@@ -113,37 +113,45 @@ let QuoteToken = (() => {
113
113
  }
114
114
  /** @private */
115
115
  lint(start = this.getAbsoluteIndex()) {
116
- const { previousSibling, bold, closing } = this, previousData = previousSibling?.type === 'text' ? previousSibling.data : undefined, errors = [], rect = new rect_1.BoundingRect(this, start), rules = ['lonely-apos', 'bold-header'], severities = [undefined, 'word'].map(key => index_1.default.lintConfig.getSeverity(rules[0], key)), s = index_1.default.lintConfig.getSeverity(rules[1]);
117
- if (previousData?.endsWith(`'`)) {
118
- const severity = severities[(closing.bold || closing.italic) && /[a-z\d]'$/iu.test(previousData) ? 1 : 0];
119
- if (severity) {
120
- const e = (0, lint_1.generateForSelf)(this, rect, rules[0], index_1.default.msg('lonely', `'`), severity), { startLine: endLine, startCol: endCol } = e, [, { length }] = /(?:^|[^'])('+)$/u.exec(previousData), startIndex = start - length, eNew = {
121
- ...e,
122
- startIndex,
123
- endIndex: start,
124
- endLine,
125
- startCol: endCol - length,
126
- endCol,
127
- };
128
- eNew.suggestions = [
129
- (0, lint_1.fixByEscape)(startIndex, '&apos;', length),
130
- (0, lint_1.fixByRemove)(eNew),
131
- ];
132
- errors.push(eNew);
116
+ LINT: { // eslint-disable-line no-unused-labels
117
+ const { previousSibling, bold, closing } = this, previousData = previousSibling?.type === 'text' ? previousSibling.data : undefined, errors = [], rect = new rect_1.BoundingRect(this, start), rules = ['lonely-apos', 'bold-header'], { lintConfig } = index_1.default, { computeEditInfo } = lintConfig, severities = [undefined, 'word'].map(key => lintConfig.getSeverity(rules[0], key)), s = lintConfig.getSeverity(rules[1]);
118
+ if (previousData?.endsWith(`'`)) {
119
+ const severity = severities[(closing.bold || closing.italic) && /[a-z\d]'$/iu.test(previousData) ? 1 : 0];
120
+ if (severity) {
121
+ const e = (0, lint_1.generateForSelf)(this, rect, rules[0], index_1.default.msg('lonely', `'`), severity), { startLine: endLine, startCol: endCol } = e, [, { length }] = /(?:^|[^'])('+)$/u.exec(previousData), startIndex = start - length, eNew = {
122
+ ...e,
123
+ startIndex,
124
+ endIndex: start,
125
+ endLine,
126
+ startCol: endCol - length,
127
+ endCol,
128
+ };
129
+ if (computeEditInfo) {
130
+ eNew.suggestions = [
131
+ (0, lint_1.fixByEscape)(startIndex, '&apos;', length),
132
+ (0, lint_1.fixByRemove)(eNew),
133
+ ];
134
+ }
135
+ errors.push(eNew);
136
+ }
133
137
  }
138
+ if (s && bold && this.closest('heading-title,ext')?.type === 'heading-title') {
139
+ const e = (0, lint_1.generateForSelf)(this, rect, rules[1], 'bold-in-header', s);
140
+ if (computeEditInfo) {
141
+ e.suggestions = [(0, lint_1.fixByRemove)(e)];
142
+ }
143
+ errors.push(e);
144
+ }
145
+ return errors;
134
146
  }
135
- if (s && bold && this.closest('heading-title,ext')?.type === 'heading-title') {
136
- const e = (0, lint_1.generateForSelf)(this, rect, rules[1], 'bold-in-header', s);
137
- e.suggestions = [(0, lint_1.fixByRemove)(e)];
138
- errors.push(e);
139
- }
140
- return errors;
141
147
  }
142
148
  /** @private */
143
149
  json(_, start = this.getAbsoluteIndex()) {
144
150
  const json = super.json(undefined, start);
145
- Object.assign(json, { bold: this.bold, italic: this.italic });
146
- return json;
151
+ LSP: { // eslint-disable-line no-unused-labels
152
+ Object.assign(json, { bold: this.bold, italic: this.italic });
153
+ return json;
154
+ }
147
155
  }
148
156
  /* NOT FOR BROWSER */
149
157
  cloneNode() {
@@ -96,35 +96,39 @@ let ParamTagToken = (() => {
96
96
  }
97
97
  /** @private */
98
98
  lint(start = this.getAbsoluteIndex()) {
99
- const rule = 'no-ignored', s = index_1.default.lintConfig.getSeverity(rule, this.name);
100
- if (!s) {
101
- return [];
102
- }
103
- const rect = new rect_1.BoundingRect(this, start), msg = index_1.default.msg('invalid-parameter', this.name), errors = [];
104
- for (const child of this.childNodes) {
105
- child.setAttribute('aIndex', start);
106
- const grandChildren = child.childNodes
107
- .filter(({ type }) => type !== 'comment' && type !== 'include' && type !== 'noinclude');
108
- if (grandChildren.some(({ type }) => type === 'ext')) {
109
- errors.push((0, lint_1.generateForChild)(child, rect, rule, msg, s));
99
+ LINT: { // eslint-disable-line no-unused-labels
100
+ const rule = 'no-ignored', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, this.name);
101
+ if (!s) {
102
+ return [];
110
103
  }
111
- else {
112
- const i = grandChildren.findIndex(({ type }) => type !== 'text'), str = grandChildren.slice(0, i === -1 ? undefined : i).map(String).join('');
113
- if (str && !(i === -1 ? /^[a-z]+(?:\[\])?\s*=/iu : /^[a-z]+(?:\[\])?\s*(?:=|$)/iu).test(str)) {
114
- const e = (0, lint_1.generateForChild)(child, rect, rule, msg, s);
115
- e.suggestions = [(0, lint_1.fixByRemove)(e)];
116
- errors.push(e);
104
+ const rect = new rect_1.BoundingRect(this, start), msg = index_1.default.msg('invalid-parameter', this.name), errors = [];
105
+ for (const child of this.childNodes) {
106
+ child.setAttribute('aIndex', start);
107
+ const grandChildren = child.childNodes
108
+ .filter(({ type }) => type !== 'comment' && type !== 'include' && type !== 'noinclude');
109
+ if (grandChildren.some(({ type }) => type === 'ext')) {
110
+ errors.push((0, lint_1.generateForChild)(child, rect, rule, msg, s));
117
111
  }
118
112
  else {
119
- const childErrors = child.lint(start, false);
120
- if (childErrors.length > 0) {
121
- errors.push(...childErrors);
113
+ const i = grandChildren.findIndex(({ type }) => type !== 'text'), str = grandChildren.slice(0, i === -1 ? undefined : i).map(String).join('');
114
+ if (str && !(i === -1 ? /^[a-z]+(?:\[\])?\s*=/iu : /^[a-z]+(?:\[\])?\s*(?:=|$)/iu).test(str)) {
115
+ const e = (0, lint_1.generateForChild)(child, rect, rule, msg, s);
116
+ if (lintConfig.computeEditInfo) {
117
+ e.suggestions = [(0, lint_1.fixByRemove)(e)];
118
+ }
119
+ errors.push(e);
120
+ }
121
+ else {
122
+ const childErrors = child.lint(start, false);
123
+ if (childErrors.length > 0) {
124
+ errors.push(...childErrors);
125
+ }
122
126
  }
123
127
  }
128
+ start += child.toString().length + 1;
124
129
  }
125
- start += child.toString().length + 1;
130
+ return errors;
126
131
  }
127
- return errors;
128
132
  }
129
133
  /* NOT FOR BROWSER */
130
134
  cloneNode() {
@@ -49,7 +49,7 @@ const fixed_1 = require("../mixin/fixed");
49
49
  /* NOT FOR BROWSER END */
50
50
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
51
51
  /https?:\/\/(?:\[[\da-f:.]+\]|[^[\]<>"\t\n\p{Zs}])[^[\]<>"\0\t\n\p{Zs}]*$/iu;
52
- const linkRegex = new RegExp(`https?://${string_1.extUrlCharFirst}${string_1.extUrlChar}$`, 'iu');
52
+ const linkRegex = /* #__PURE__ */ (() => new RegExp(`https?://${string_1.extUrlCharFirst}${string_1.extUrlChar}$`, 'iu'))();
53
53
  /**
54
54
  * template or magic word parameter
55
55
  *
@@ -82,11 +82,13 @@ let ParameterToken = (() => {
82
82
  /* PRINT ONLY */
83
83
  /** whether to be a duplicated parameter / 是否是重复参数 */
84
84
  get duplicated() {
85
- try {
86
- return Boolean(this.parentNode?.getDuplicatedArgs().some(([key]) => key === this.name));
87
- }
88
- catch {
89
- return false;
85
+ LSP: { // eslint-disable-line no-unused-labels
86
+ try {
87
+ return Boolean(this.parentNode?.getDuplicatedArgs().some(([key]) => key === this.name));
88
+ }
89
+ catch {
90
+ return false;
91
+ }
90
92
  }
91
93
  }
92
94
  /* PRINT ONLY END */
@@ -175,24 +177,28 @@ let ParameterToken = (() => {
175
177
  }
176
178
  /** @private */
177
179
  lint(start = this.getAbsoluteIndex(), re) {
178
- const errors = super.lint(start, re), rule = 'unescaped', s = index_1.default.lintConfig.getSeverity(rule);
179
- if (s) {
180
- const { firstChild } = this, link = linkRegex.exec(firstChild.text())?.[0];
181
- try {
182
- if (link && new URL(link).search) {
183
- const e = (0, lint_1.generateForChild)(firstChild, { start }, rule, 'unescaped-query', s);
184
- e.startIndex = e.endIndex;
185
- e.startLine = e.endLine;
186
- e.startCol = e.endCol;
187
- e.endIndex++;
188
- e.endCol++;
189
- e.fix = (0, lint_1.fixByEscape)(e.startIndex, '{{=}}');
190
- errors.push(e);
180
+ LINT: { // eslint-disable-line no-unused-labels
181
+ const errors = super.lint(start, re), rule = 'unescaped', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule);
182
+ if (s) {
183
+ const { firstChild } = this, link = linkRegex.exec(firstChild.text())?.[0];
184
+ try {
185
+ if (link && new URL(link).search) {
186
+ const e = (0, lint_1.generateForChild)(firstChild, { start }, rule, 'unescaped-query', s);
187
+ e.startIndex = e.endIndex;
188
+ e.startLine = e.endLine;
189
+ e.startCol = e.endCol;
190
+ e.endIndex++;
191
+ e.endCol++;
192
+ if (lintConfig.computeEditInfo || lintConfig.fix) {
193
+ e.fix = (0, lint_1.fixByEscape)(e.startIndex, '{{=}}');
194
+ }
195
+ errors.push(e);
196
+ }
191
197
  }
198
+ catch { }
192
199
  }
193
- catch { }
200
+ return errors;
194
201
  }
195
- return errors;
196
202
  }
197
203
  /** @private */
198
204
  print() {
@@ -201,8 +207,10 @@ let ParameterToken = (() => {
201
207
  /** @private */
202
208
  json(_, start = this.getAbsoluteIndex()) {
203
209
  const json = super.json(undefined, start);
204
- Object.assign(json, { anon: this.anon }, this.duplicated && { duplicated: true });
205
- return json;
210
+ LSP: { // eslint-disable-line no-unused-labels
211
+ Object.assign(json, { anon: this.anon }, this.duplicated && { duplicated: true });
212
+ return json;
213
+ }
206
214
  }
207
215
  /* NOT FOR BROWSER */
208
216
  cloneNode() {
package/dist/src/pre.js CHANGED
@@ -96,7 +96,7 @@ let PreToken = (() => {
96
96
  }
97
97
  /** @private */
98
98
  lint(start = this.getAbsoluteIndex()) {
99
- return super.lint(start, /<\s*\/\s*(pre)\b/giu);
99
+ LINT: return super.lint(start, /<\s*\/\s*(pre)\b/giu); // eslint-disable-line no-unused-labels
100
100
  }
101
101
  /* NOT FOR BROWSER */
102
102
  cloneNode() {
@@ -100,9 +100,11 @@ let RedirectToken = (() => {
100
100
  }
101
101
  /** @private */
102
102
  lint(start = this.getAbsoluteIndex()) {
103
- const index = start + this.#pre.length + this.firstChild.toString().length;
104
- this.lastChild.setAttribute('aIndex', index);
105
- return this.lastChild.lint(index);
103
+ LINT: { // eslint-disable-line no-unused-labels
104
+ const index = start + this.#pre.length + this.firstChild.toString().length;
105
+ this.lastChild.setAttribute('aIndex', index);
106
+ return this.lastChild.lint(index);
107
+ }
106
108
  }
107
109
  /** @private */
108
110
  print() {
@@ -80,7 +80,7 @@ let SyntaxToken = (() => {
80
80
  }
81
81
  /** @private */
82
82
  lint(start = this.getAbsoluteIndex()) {
83
- return super.lint(start, false);
83
+ LINT: return super.lint(start, false); // eslint-disable-line no-unused-labels
84
84
  }
85
85
  /* NOT FOR BROWSER */
86
86
  cloneNode() {
@@ -138,40 +138,42 @@ let TableToken = (() => {
138
138
  }
139
139
  /** @private */
140
140
  lint(start = this.getAbsoluteIndex(), re) {
141
- const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start), rules = ['unclosed-table', 'table-layout'], s = rules.map(rule => index_1.default.lintConfig.getSeverity(rule));
142
- if (s[0] && !this.closed) {
143
- errors.push((0, lint_1.generateForChild)(this.firstChild, rect, rules[0], index_1.default.msg('unclosed', 'table'), s[0]));
144
- }
145
- if (s[1]) {
146
- const layout = this.getLayout(), { length } = layout;
147
- if (length > 1) {
148
- let low = 1, high = Infinity, j = 0;
149
- for (; j < length; j++) {
150
- const row = layout[j], max = row.length;
151
- if (max < low) {
152
- break;
153
- }
154
- else if (max < high) {
155
- high = max;
156
- }
157
- const min = row.indexOf(row[max - 1]) + 1;
158
- if (min > high) {
159
- break;
141
+ LINT: { // eslint-disable-line no-unused-labels
142
+ const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start), rules = ['unclosed-table', 'table-layout'], s = rules.map(rule => index_1.default.lintConfig.getSeverity(rule));
143
+ if (s[0] && !this.closed) {
144
+ errors.push((0, lint_1.generateForChild)(this.firstChild, rect, rules[0], index_1.default.msg('unclosed', 'table'), s[0]));
145
+ }
146
+ if (s[1]) {
147
+ const layout = this.getLayout(), { length } = layout;
148
+ if (length > 1) {
149
+ let low = 1, high = Infinity, j = 0;
150
+ for (; j < length; j++) {
151
+ const row = layout[j], max = row.length;
152
+ if (max < low) {
153
+ break;
154
+ }
155
+ else if (max < high) {
156
+ high = max;
157
+ }
158
+ const min = row.indexOf(row[max - 1]) + 1;
159
+ if (min > high) {
160
+ break;
161
+ }
162
+ else if (min > low) {
163
+ low = min;
164
+ }
160
165
  }
161
- else if (min > low) {
162
- low = min;
166
+ if (j < length) {
167
+ const row = this.getNthRow(j), e = (0, lint_1.generateForChild)(row, rect, rules[1], 'inconsistent-table', s[1]);
168
+ e.startIndex++;
169
+ e.startLine++;
170
+ e.startCol = 0;
171
+ errors.push(e);
163
172
  }
164
173
  }
165
- if (j < length) {
166
- const row = this.getNthRow(j), e = (0, lint_1.generateForChild)(row, rect, rules[1], 'inconsistent-table', s[1]);
167
- e.startIndex++;
168
- e.startLine++;
169
- e.startCol = 0;
170
- errors.push(e);
171
- }
172
174
  }
175
+ return errors;
173
176
  }
174
- return errors;
175
177
  }
176
178
  // eslint-disable-next-line jsdoc/require-param
177
179
  /**
@@ -303,8 +305,10 @@ let TableToken = (() => {
303
305
  /** @private */
304
306
  json(_, start = this.getAbsoluteIndex()) {
305
307
  const json = super.json(undefined, start);
306
- json['closed'] = this.closed;
307
- return json;
308
+ LSP: { // eslint-disable-line no-unused-labels
309
+ json['closed'] = this.closed;
310
+ return json;
311
+ }
308
312
  }
309
313
  /* NOT FOR BROWSER */
310
314
  /**