wikiparser-node 1.25.1 → 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 (49) hide show
  1. package/bundle/bundle-es8.min.js +25 -25
  2. package/bundle/bundle-lsp.min.js +30 -30
  3. package/bundle/bundle.min.js +20 -20
  4. package/config/default.json +3 -0
  5. package/config/enwiki.json +3 -0
  6. package/config/jawiki.json +3 -0
  7. package/config/minimum.json +1 -0
  8. package/config/moegirl.json +0 -20
  9. package/config/zhwiki.json +3 -0
  10. package/data/ext/math.json +41 -0
  11. package/dist/base.d.mts +15 -3
  12. package/dist/base.d.ts +15 -3
  13. package/dist/bin/config.js +8 -2
  14. package/dist/index.d.ts +2 -1
  15. package/dist/index.js +2 -3
  16. package/dist/lib/element.js +1 -1
  17. package/dist/lib/lintConfig.d.ts +18 -7
  18. package/dist/lib/lintConfig.js +55 -15
  19. package/dist/lib/lsp.js +16 -8
  20. package/dist/lib/text.js +35 -33
  21. package/dist/src/arg.js +8 -6
  22. package/dist/src/attribute.js +23 -13
  23. package/dist/src/attributes.js +23 -15
  24. package/dist/src/converterFlags.js +9 -7
  25. package/dist/src/gallery.js +7 -5
  26. package/dist/src/heading.js +35 -25
  27. package/dist/src/html.js +38 -29
  28. package/dist/src/imageParameter.js +9 -5
  29. package/dist/src/imagemap.js +7 -5
  30. package/dist/src/index.js +50 -41
  31. package/dist/src/link/base.js +19 -11
  32. package/dist/src/link/file.js +24 -18
  33. package/dist/src/link/galleryImage.js +4 -2
  34. package/dist/src/link/index.js +4 -2
  35. package/dist/src/link/redirectTarget.js +4 -2
  36. package/dist/src/magicLink.js +13 -10
  37. package/dist/src/nested.js +7 -5
  38. package/dist/src/nowiki/comment.js +4 -2
  39. package/dist/src/nowiki/index.js +4 -2
  40. package/dist/src/nowiki/quote.js +10 -6
  41. package/dist/src/paramTag/index.js +4 -2
  42. package/dist/src/parameter.js +4 -2
  43. package/dist/src/table/td.js +9 -7
  44. package/dist/src/tagPair/ext.js +3 -3
  45. package/dist/src/tagPair/include.js +7 -3
  46. package/dist/src/transclude.js +13 -7
  47. package/extensions/dist/base.js +1 -1
  48. package/extensions/editor.css +2 -2
  49. package/package.json +5 -5
@@ -197,20 +197,24 @@ class ImageParameterToken extends index_2.Token {
197
197
  /** @private */
198
198
  lint(start = this.getAbsoluteIndex(), re) {
199
199
  LINT: { // eslint-disable-line no-unused-labels
200
- const errors = super.lint(start, re), { link, name } = this;
200
+ const errors = super.lint(start, re), { lintConfig } = index_1.default, { computeEditInfo, fix } = lintConfig, { link, name } = this;
201
201
  if (name === 'invalid') {
202
- const rule = 'invalid-gallery', s = index_1.default.lintConfig.getSeverity(rule, 'parameter');
202
+ const rule = 'invalid-gallery', s = lintConfig.getSeverity(rule, 'parameter');
203
203
  if (s) {
204
204
  const e = (0, lint_1.generateForSelf)(this, { start }, rule, 'invalid-image-parameter', s);
205
- e.fix = (0, lint_1.fixByRemove)(e, -1);
205
+ if (computeEditInfo || fix) {
206
+ e.fix = (0, lint_1.fixByRemove)(e, -1);
207
+ }
206
208
  errors.push(e);
207
209
  }
208
210
  }
209
211
  else if (typeof link === 'object' && link.encoded) {
210
- const rule = 'url-encoding', s = index_1.default.lintConfig.getSeverity(rule, 'file');
212
+ const rule = 'url-encoding', s = lintConfig.getSeverity(rule, 'file');
211
213
  if (s) {
212
214
  const e = (0, lint_1.generateForSelf)(this, { start }, rule, 'unnecessary-encoding', s);
213
- e.fix = (0, lint_1.fixByDecode)(e, this);
215
+ if (computeEditInfo || fix) {
216
+ e.fix = (0, lint_1.fixByDecode)(e, this);
217
+ }
214
218
  errors.push(e);
215
219
  }
216
220
  }
@@ -149,7 +149,7 @@ let ImagemapToken = (() => {
149
149
  /** @private */
150
150
  lint(start = this.getAbsoluteIndex(), re) {
151
151
  LINT: { // eslint-disable-line no-unused-labels
152
- const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start), { childNodes, image } = this, rule = 'invalid-imagemap', s = index_1.default.lintConfig.getSeverity(rule, image ? 'link' : 'image');
152
+ const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start), { childNodes, image } = this, rule = 'invalid-imagemap', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, image ? 'link' : 'image');
153
153
  if (s) {
154
154
  if (image) {
155
155
  errors.push(...childNodes.filter(child => {
@@ -157,10 +157,12 @@ let ImagemapToken = (() => {
157
157
  return child.is('noinclude') && str && !str.startsWith('#');
158
158
  }).map(child => {
159
159
  const e = (0, lint_1.generateForChild)(child, rect, rule, 'invalid-imagemap-link', s);
160
- e.suggestions = [
161
- (0, lint_1.fixByRemove)(e, -1),
162
- (0, lint_1.fixBy)(e, 'comment', '# '),
163
- ];
160
+ if (lintConfig.computeEditInfo) {
161
+ e.suggestions = [
162
+ (0, lint_1.fixByRemove)(e, -1),
163
+ (0, lint_1.fixBy)(e, 'comment', '# '),
164
+ ];
165
+ }
164
166
  return e;
165
167
  }));
166
168
  }
package/dist/src/index.js CHANGED
@@ -525,9 +525,10 @@ let Token = (() => {
525
525
  /** @private */
526
526
  lint(start = this.getAbsoluteIndex(), re) {
527
527
  LINT: { // eslint-disable-line no-unused-labels
528
+ const { lintConfig } = index_1.default, { computeEditInfo, fix: needFix, ignoreDisables, configurationComment } = lintConfig;
528
529
  let errors = super.lint(start, re);
529
530
  if (this.type === 'root') {
530
- const record = new Map(), r = 'no-duplicate', s = ['category', 'id'].map(key => index_1.default.lintConfig.getSeverity(r, key)), selector = lintSelectors.filter((_, i) => s[i]).join();
531
+ const record = new Map(), r = 'no-duplicate', s = ['category', 'id'].map(key => lintConfig.getSeverity(r, key)), wikitext = this.toString(), selector = lintSelectors.filter((_, i) => s[i]).join();
531
532
  if (selector) {
532
533
  for (const cat of this.querySelectorAll(selector)) {
533
534
  let key;
@@ -555,7 +556,7 @@ let Token = (() => {
555
556
  const isCat = !key.startsWith('#'), msg = `duplicate-${isCat ? 'category' : 'id'}`, severity = s[isCat ? 0 : 1];
556
557
  errors.push(...[...value].map(cat => {
557
558
  const e = (0, lint_1.generateForSelf)(cat, { start: cat.getAbsoluteIndex() }, r, msg, severity);
558
- if (isCat) {
559
+ if (computeEditInfo && isCat) {
559
560
  e.suggestions = [(0, lint_1.fixByRemove)(e)];
560
561
  }
561
562
  return e;
@@ -563,42 +564,44 @@ let Token = (() => {
563
564
  }
564
565
  }
565
566
  }
566
- const regex = /<!--\s*lint-(disable(?:(?:-next)?-line)?|enable)(\s[\sa-z,-]*)?-->/gu, wikitext = this.toString(), ignores = [];
567
- let mt = regex.exec(wikitext);
568
- while (mt) {
569
- const { 1: type, index } = mt, detail = mt[2]?.trim();
570
- ignores.push({
571
- line: this.posFromIndex(index).top + (type === 'disable-line' ? 0 : 1),
572
- from: type === 'disable' ? regex.lastIndex : undefined,
573
- to: type === 'enable' ? regex.lastIndex : undefined,
574
- rules: detail ? new Set(detail.split(',').map(rule => rule.trim())) : undefined,
567
+ if (!ignoreDisables) {
568
+ const regex = new RegExp(String.raw `<!--\s*${configurationComment}-(disable(?:(?:-next)?-line)?|enable)(\s[\sa-z,-]*)?-->`, 'gu'), ignores = [];
569
+ let mt = regex.exec(wikitext);
570
+ while (mt) {
571
+ const { 1: type, index } = mt, detail = mt[2]?.trim();
572
+ ignores.push({
573
+ line: this.posFromIndex(index).top + (type === 'disable-line' ? 0 : 1),
574
+ from: type === 'disable' ? regex.lastIndex : undefined,
575
+ to: type === 'enable' ? regex.lastIndex : undefined,
576
+ rules: detail ? new Set(detail.split(',').map(rule => rule.trim())) : undefined,
577
+ });
578
+ mt = regex.exec(wikitext);
579
+ }
580
+ errors = errors.filter(({ rule, startLine, startIndex }) => {
581
+ const nearest = { pos: 0 };
582
+ for (const { line, from, to, rules } of ignores) {
583
+ if (line > startLine + 1) {
584
+ break;
585
+ }
586
+ else if (rules && !rules.has(rule)) {
587
+ continue;
588
+ }
589
+ else if (line === startLine && from === undefined && to === undefined) {
590
+ return false;
591
+ }
592
+ else if (from <= startIndex && from > nearest.pos) {
593
+ nearest.pos = from;
594
+ nearest.type = 'from';
595
+ }
596
+ else if (to <= startIndex && to > nearest.pos) {
597
+ nearest.pos = to;
598
+ nearest.type = 'to';
599
+ }
600
+ }
601
+ return nearest.type !== 'from';
575
602
  });
576
- mt = regex.exec(wikitext);
577
603
  }
578
- errors = errors.filter(({ rule, startLine, startIndex }) => {
579
- const nearest = { pos: 0 };
580
- for (const { line, from, to, rules } of ignores) {
581
- if (line > startLine + 1) {
582
- break;
583
- }
584
- else if (rules && !rules.has(rule)) {
585
- continue;
586
- }
587
- else if (line === startLine && from === undefined && to === undefined) {
588
- return false;
589
- }
590
- else if (from <= startIndex && from > nearest.pos) {
591
- nearest.pos = from;
592
- nearest.type = 'from';
593
- }
594
- else if (to <= startIndex && to > nearest.pos) {
595
- nearest.pos = to;
596
- nearest.type = 'to';
597
- }
598
- }
599
- return nearest.type !== 'from';
600
- });
601
- if (errors.some(({ fix }) => fix)) {
604
+ if (needFix && errors.some(({ fix }) => fix)) {
602
605
  // 倒序修复,跳过嵌套的修复
603
606
  const fixable = errors.map(({ fix }) => fix).filter(Boolean).sort(({ range: [aFrom, aTo] }, { range: [bFrom, bTo] }) => aTo === bTo ? bFrom - aFrom : bTo - aTo);
604
607
  let i = Infinity, output = wikitext;
@@ -610,20 +613,26 @@ let Token = (() => {
610
613
  }
611
614
  Object.assign(errors, { output });
612
615
  }
616
+ if (!computeEditInfo) {
617
+ for (const e of errors) {
618
+ delete e.fix;
619
+ delete e.suggestions;
620
+ }
621
+ }
613
622
  /* NOT FOR BROWSER ONLY */
614
623
  }
615
- else if (index_1.default.lintCSS && (0, lsp_1.isAttr)(this, true)) {
616
- const rule = 'invalid-css', s = index_1.default.lintConfig.getSeverity(rule), sWarn = index_1.default.lintConfig.getSeverity(rule, 'warn');
617
- if (s) {
624
+ else if ((0, lsp_1.isAttr)(this, true)) {
625
+ const rule = 'invalid-css', s = lintConfig.getSeverity(rule), sWarn = lintConfig.getSeverity(rule, 'warn');
626
+ if (s || sWarn) {
618
627
  const root = this.getRootNode(), textDoc = new document_1.EmbeddedCSSDocument(root, this);
619
628
  errors.push(...document_1.cssLSP.doValidation(textDoc, textDoc.styleSheet)
620
629
  .filter(({ code, severity }) => code !== 'css-ruleorselectorexpected' && code !== 'emptyRules'
621
- && (sWarn || severity === 1))
630
+ && (severity === 1 ? s : sWarn))
622
631
  .map(({ range: { start: { line, character }, end }, message, severity, code }) => ({
623
632
  code: code,
624
633
  rule: 'invalid-css',
625
634
  message,
626
- severity: severity === 1 ? s : sWarn,
635
+ severity: (severity === 1 ? s : sWarn),
627
636
  startLine: line,
628
637
  startCol: character,
629
638
  startIndex: root.indexFromPos(line, character),
@@ -215,34 +215,42 @@ let LinkBaseToken = (() => {
215
215
  /** @private */
216
216
  lint(start = this.getAbsoluteIndex(), re) {
217
217
  LINT: { // eslint-disable-line no-unused-labels
218
- const errors = super.lint(start, re), { childNodes: [target, linkText], type } = this, { encoded, fragment } = this.#title, rect = new rect_1.BoundingRect(this, start);
219
- let rule = 'unknown-page', s = index_1.default.lintConfig.getSeverity(rule);
218
+ const errors = super.lint(start, re), { childNodes: [target, linkText], type } = this, { encoded, fragment } = this.#title, { lintConfig } = index_1.default, { computeEditInfo, fix } = lintConfig, rect = new rect_1.BoundingRect(this, start);
219
+ let rule = 'unknown-page', s = lintConfig.getSeverity(rule);
220
220
  if (s && target.childNodes.some(({ type: t }) => t === 'template')) {
221
221
  errors.push((0, lint_1.generateForChild)(target, rect, rule, 'template-in-link', s));
222
222
  }
223
223
  rule = 'url-encoding';
224
- s = index_1.default.lintConfig.getSeverity(rule);
224
+ s = lintConfig.getSeverity(rule);
225
225
  if (s && encoded) {
226
226
  const e = (0, lint_1.generateForChild)(target, rect, rule, 'unnecessary-encoding', s);
227
- e.fix = (0, lint_1.fixByDecode)(e, target);
227
+ if (computeEditInfo || fix) {
228
+ e.fix = (0, lint_1.fixByDecode)(e, target);
229
+ }
228
230
  errors.push(e);
229
231
  }
230
232
  rule = 'pipe-like';
231
- s = index_1.default.lintConfig.getSeverity(rule, 'link');
233
+ s = lintConfig.getSeverity(rule, 'link');
232
234
  if (s && (type === 'link' || type === 'category')) {
233
235
  const j = linkText?.childNodes.findIndex(c => c.type === 'text' && c.data.includes('|')), textNode = linkText?.childNodes[j];
234
236
  if (textNode) {
235
- const e = (0, lint_1.generateForChild)(linkText, rect, rule, 'pipe-in-link', s), i = e.startIndex + linkText.getRelativeIndex(j);
236
- e.suggestions = [(0, lint_1.fixByPipe)(i, textNode.data)];
237
+ const e = (0, lint_1.generateForChild)(linkText, rect, rule, 'pipe-in-link', s);
238
+ if (computeEditInfo) {
239
+ const i = e.startIndex + linkText.getRelativeIndex(j);
240
+ e.suggestions = [(0, lint_1.fixByPipe)(i, textNode.data)];
241
+ }
237
242
  errors.push(e);
238
243
  }
239
244
  }
240
245
  rule = 'no-ignored';
241
- s = index_1.default.lintConfig.getSeverity(rule, 'fragment');
246
+ s = lintConfig.getSeverity(rule, 'fragment');
242
247
  if (s && fragment !== undefined && !isLink(type)) {
243
- const e = (0, lint_1.generateForChild)(target, rect, rule, 'useless-fragment', s), j = target.childNodes.findIndex(c => c.type === 'text' && c.data.includes('#')), textNode = target.childNodes[j];
244
- if (textNode) {
245
- e.fix = (0, lint_1.fixByRemove)(e, target.getRelativeIndex(j) + textNode.data.indexOf('#'));
248
+ const e = (0, lint_1.generateForChild)(target, rect, rule, 'useless-fragment', s);
249
+ if (computeEditInfo || fix) {
250
+ const j = target.childNodes.findIndex(c => c.type === 'text' && c.data.includes('#')), textNode = target.childNodes[j];
251
+ if (textNode) {
252
+ e.fix = (0, lint_1.fixByRemove)(e, target.getRelativeIndex(j) + textNode.data.indexOf('#'));
253
+ }
246
254
  }
247
255
  errors.push(e);
248
256
  }
@@ -185,32 +185,37 @@ let FileToken = (() => {
185
185
  /** @private */
186
186
  lint(start = this.getAbsoluteIndex(), re) {
187
187
  LINT: { // eslint-disable-line no-unused-labels
188
- const errors = super.lint(start, re), args = filterArgs(this.getAllArgs(), argTypes), keys = [...new Set(args.map(({ name }) => name))], frameKeys = keys.filter(key => frame.has(key)), horizAlignKeys = keys.filter(key => horizAlign.has(key)), vertAlignKeys = keys.filter(key => vertAlign.has(key)), [fr] = frameKeys, unscaled = fr === 'framed' || fr === 'manualthumb', rect = new rect_1.BoundingRect(this, start), { extension } = this;
189
- let rule = 'nested-link', s = index_1.default.lintConfig.getSeverity(rule, 'file');
188
+ const errors = super.lint(start, re), args = filterArgs(this.getAllArgs(), argTypes), keys = [...new Set(args.map(({ name }) => name))], frameKeys = keys.filter(key => frame.has(key)), horizAlignKeys = keys.filter(key => horizAlign.has(key)), vertAlignKeys = keys.filter(key => vertAlign.has(key)), [fr] = frameKeys, unscaled = fr === 'framed' || fr === 'manualthumb', rect = new rect_1.BoundingRect(this, start), { lintConfig } = index_1.default, { computeEditInfo, fix } = lintConfig, { extension } = this;
189
+ let rule = 'nested-link', s = lintConfig.getSeverity(rule, 'file');
190
190
  if (s
191
191
  && extensions.has(extension)
192
192
  && this.closest('ext-link-text')
193
193
  && this.getValue('link')?.trim() !== '') {
194
- const e = (0, lint_1.generateForSelf)(this, rect, rule, 'link-in-extlink', s), link = this.getArg('link');
195
- if (link) {
196
- const from = start + link.getRelativeIndex();
197
- e.fix = {
198
- desc: index_1.default.msg('delink'),
199
- range: [from, from + link.toString().length],
200
- text: 'link=',
201
- };
202
- }
203
- else {
204
- e.fix = (0, lint_1.fixByInsert)(e.endIndex - 2, 'delink', '|link=');
194
+ const e = (0, lint_1.generateForSelf)(this, rect, rule, 'link-in-extlink', s);
195
+ if (computeEditInfo || fix) {
196
+ const link = this.getArg('link');
197
+ if (link) {
198
+ const from = start + link.getRelativeIndex();
199
+ e.fix = {
200
+ desc: index_1.default.msg('delink'),
201
+ range: [from, from + link.toString().length],
202
+ text: 'link=',
203
+ };
204
+ }
205
+ else {
206
+ e.fix = (0, lint_1.fixByInsert)(e.endIndex - 2, 'delink', '|link=');
207
+ }
205
208
  }
206
209
  errors.push(e);
207
210
  }
208
211
  rule = 'invalid-gallery';
209
- s = index_1.default.lintConfig.getSeverity(rule, 'parameter');
212
+ s = lintConfig.getSeverity(rule, 'parameter');
210
213
  if (s && unscaled) {
211
214
  for (const arg of args.filter(({ name }) => name === 'width')) {
212
215
  const e = (0, lint_1.generateForChild)(arg, rect, rule, 'invalid-image-parameter', s);
213
- e.fix = (0, lint_1.fixByRemove)(e, -1);
216
+ if (computeEditInfo || fix) {
217
+ e.fix = (0, lint_1.fixByRemove)(e, -1);
218
+ }
214
219
  errors.push(e);
215
220
  }
216
221
  }
@@ -221,8 +226,7 @@ let FileToken = (() => {
221
226
  return errors;
222
227
  }
223
228
  rule = 'no-duplicate';
224
- const severities = ['unknownImageParameter', 'imageParameter']
225
- .map(k => index_1.default.lintConfig.getSeverity(rule, k));
229
+ const severities = ['unknownImageParameter', 'imageParameter'].map(k => lintConfig.getSeverity(rule, k));
226
230
  /**
227
231
  * 图片参数到语法错误的映射
228
232
  * @param tokens 图片参数节点
@@ -237,7 +241,9 @@ let FileToken = (() => {
237
241
  }
238
242
  /** `conflicting-image-parameter`或`duplicate-image-parameter` */
239
243
  const e = (0, lint_1.generateForChild)(arg, rect, rule, index_1.default.msg(`${msg}-image-parameter`, p1), s);
240
- e.suggestions = [(0, lint_1.fixByRemove)(e, -1)];
244
+ if (computeEditInfo) {
245
+ e.suggestions = [(0, lint_1.fixByRemove)(e, -1)];
246
+ }
241
247
  return e;
242
248
  }).filter((e) => e !== false);
243
249
  for (const key of keys) {
@@ -121,10 +121,12 @@ let GalleryImageToken = (() => {
121
121
  /** @private */
122
122
  lint(start = this.getAbsoluteIndex(), re) {
123
123
  LINT: { // eslint-disable-line no-unused-labels
124
- const errors = super.lint(start, re), rule = 'invalid-gallery', s = index_1.default.lintConfig.getSeverity(rule, 'image');
124
+ const errors = super.lint(start, re), rule = 'invalid-gallery', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, 'image');
125
125
  if (s && this.#lint()) {
126
126
  const e = (0, lint_1.generateForSelf)(this, { start }, rule, 'invalid-gallery', s);
127
- e.suggestions = [(0, lint_1.fixByInsert)(start, 'prefix', 'File:')];
127
+ if (lintConfig.computeEditInfo) {
128
+ e.suggestions = [(0, lint_1.fixByInsert)(start, 'prefix', 'File:')];
129
+ }
128
130
  errors.push(e);
129
131
  }
130
132
  return errors;
@@ -47,10 +47,12 @@ class LinkToken extends base_1.LinkBaseToken {
47
47
  /** @private */
48
48
  lint(start = this.getAbsoluteIndex(), re) {
49
49
  LINT: { // eslint-disable-line no-unused-labels
50
- const errors = super.lint(start, re), rule = 'nested-link', s = index_1.default.lintConfig.getSeverity(rule);
50
+ const errors = super.lint(start, re), rule = 'nested-link', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule);
51
51
  if (s && this.closest('ext-link-text')) {
52
52
  const e = (0, lint_1.generateForSelf)(this, { start }, rule, 'link-in-extlink', s);
53
- e.fix = (0, lint_1.fixBy)(e, 'delink', this.innerText);
53
+ if (lintConfig.computeEditInfo || lintConfig.fix) {
54
+ e.fix = (0, lint_1.fixBy)(e, 'delink', this.innerText);
55
+ }
54
56
  errors.push(e);
55
57
  }
56
58
  return errors;
@@ -55,12 +55,14 @@ class RedirectTargetToken extends base_1.LinkBaseToken {
55
55
  /** @private */
56
56
  lint(start = this.getAbsoluteIndex()) {
57
57
  LINT: { // eslint-disable-line no-unused-labels
58
- const errors = super.lint(start, false), rule = 'no-ignored', s = index_1.default.lintConfig.getSeverity(rule, 'redirect');
58
+ const errors = super.lint(start, false), rule = 'no-ignored', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, 'redirect');
59
59
  if (s && this.length === 2) {
60
60
  const e = (0, lint_1.generateForChild)(this.lastChild, { start }, rule, 'useless-link-text', s);
61
61
  e.startIndex--;
62
62
  e.startCol--;
63
- e.fix = (0, lint_1.fixByRemove)(e);
63
+ if (lintConfig.computeEditInfo || lintConfig.fix) {
64
+ e.fix = (0, lint_1.fixByRemove)(e);
65
+ }
64
66
  errors.push(e);
65
67
  }
66
68
  return errors;
@@ -180,25 +180,28 @@ let MagicLinkToken = (() => {
180
180
  /** @private */
181
181
  lint(start = this.getAbsoluteIndex(), re) {
182
182
  LINT: { // eslint-disable-line no-unused-labels
183
- const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start), { type, childNodes } = this;
183
+ const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start), { lintConfig } = index_1.default, { type, childNodes } = this;
184
184
  if (type === 'magic-link') {
185
- const rule = 'invalid-isbn', s = index_1.default.lintConfig.getSeverity(rule);
185
+ const rule = 'invalid-isbn', s = lintConfig.getSeverity(rule);
186
186
  if (s && this.#lint()) {
187
187
  errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'invalid-isbn', s));
188
188
  }
189
189
  return errors;
190
190
  }
191
- const pipe = type === 'ext-link-url', rule = 'unterminated-url', severity = index_1.default.lintConfig.getSeverity(rule, pipe ? 'pipe' : 'punctuation');
191
+ const pipe = type === 'ext-link-url', rule = 'unterminated-url', severity = lintConfig.getSeverity(rule, pipe ? 'pipe' : 'punctuation');
192
192
  if (severity) {
193
193
  const regex = pipe ? /\|/u : /[,;。:!?()]+/u, child = childNodes.find((c) => c.type === 'text' && regex.test(c.data));
194
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), { index, 0: s } = regex.exec(data), i = e.startIndex + index;
196
- e.suggestions = pipe
197
- ? [(0, lint_1.fixBySpace)(i, 1)]
198
- : [
199
- (0, lint_1.fixBySpace)(i),
200
- { desc: index_1.default.msg('encode'), range: [i, i + s.length], text: encodeURI(s) },
201
- ];
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
+ }
202
205
  errors.push(e);
203
206
  }
204
207
  }
@@ -111,7 +111,7 @@ let NestedToken = (() => {
111
111
  /** @private */
112
112
  lint(start = this.getAbsoluteIndex(), re) {
113
113
  LINT: { // eslint-disable-line no-unused-labels
114
- const errors = super.lint(start, re), rule = 'no-ignored', s = index_1.default.lintConfig.getSeverity(rule, this.name);
114
+ const errors = super.lint(start, re), rule = 'no-ignored', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, this.name);
115
115
  if (!s) {
116
116
  return errors;
117
117
  }
@@ -130,10 +130,12 @@ let NestedToken = (() => {
130
130
  return str && !regex.test(str);
131
131
  }).map(child => {
132
132
  const e = (0, lint_1.generateForChild)(child, rect, rule, index_1.default.msg('invalid-content', this.name), s);
133
- e.suggestions = [
134
- (0, lint_1.fixByRemove)(e),
135
- (0, lint_1.fixByComment)(e, child.toString()),
136
- ];
133
+ if (lintConfig.computeEditInfo) {
134
+ e.suggestions = [
135
+ (0, lint_1.fixByRemove)(e),
136
+ (0, lint_1.fixByComment)(e, child.toString()),
137
+ ];
138
+ }
137
139
  return e;
138
140
  }),
139
141
  ];
@@ -91,12 +91,14 @@ let CommentToken = (() => {
91
91
  if (this.closed) {
92
92
  return [];
93
93
  }
94
- const rule = 'unclosed-comment', s = index_1.default.lintConfig.getSeverity(rule);
94
+ const rule = 'unclosed-comment', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule);
95
95
  if (!s) {
96
96
  return [];
97
97
  }
98
98
  const e = (0, lint_1.generateForSelf)(this, { start }, rule, index_1.default.msg('unclosed', 'html-comment'), s);
99
- e.suggestions = [(0, lint_1.fixByClose)(e.endIndex, '-->')];
99
+ if (lintConfig.computeEditInfo) {
100
+ e.suggestions = [(0, lint_1.fixByClose)(e.endIndex, '-->')];
101
+ }
100
102
  return [e];
101
103
  }
102
104
  }
@@ -32,10 +32,12 @@ class NowikiToken extends base_1.NowikiBaseToken {
32
32
  /** @private */
33
33
  lint(start = this.getAbsoluteIndex()) {
34
34
  LINT: { // eslint-disable-line no-unused-labels
35
- const { name } = this, rule = 'void-ext', s = index_1.default.lintConfig.getSeverity(rule, name);
35
+ const { name } = this, rule = 'void-ext', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, name);
36
36
  if (s && this.#lint()) {
37
37
  const e = (0, lint_1.generateForSelf)(this, { start }, rule, index_1.default.msg('nothing-in', name), s);
38
- e.suggestions = [(0, lint_1.fixByRemove)(e)];
38
+ if (lintConfig.computeEditInfo) {
39
+ e.suggestions = [(0, lint_1.fixByRemove)(e)];
40
+ }
39
41
  return [e];
40
42
  }
41
43
  return super.lint(start, getLintRegex(name));
@@ -114,7 +114,7 @@ let QuoteToken = (() => {
114
114
  /** @private */
115
115
  lint(start = this.getAbsoluteIndex()) {
116
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'], severities = [undefined, 'word'].map(key => index_1.default.lintConfig.getSeverity(rules[0], key)), s = index_1.default.lintConfig.getSeverity(rules[1]);
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
118
  if (previousData?.endsWith(`'`)) {
119
119
  const severity = severities[(closing.bold || closing.italic) && /[a-z\d]'$/iu.test(previousData) ? 1 : 0];
120
120
  if (severity) {
@@ -126,16 +126,20 @@ let QuoteToken = (() => {
126
126
  startCol: endCol - length,
127
127
  endCol,
128
128
  };
129
- eNew.suggestions = [
130
- (0, lint_1.fixByEscape)(startIndex, '&apos;', length),
131
- (0, lint_1.fixByRemove)(eNew),
132
- ];
129
+ if (computeEditInfo) {
130
+ eNew.suggestions = [
131
+ (0, lint_1.fixByEscape)(startIndex, '&apos;', length),
132
+ (0, lint_1.fixByRemove)(eNew),
133
+ ];
134
+ }
133
135
  errors.push(eNew);
134
136
  }
135
137
  }
136
138
  if (s && bold && this.closest('heading-title,ext')?.type === 'heading-title') {
137
139
  const e = (0, lint_1.generateForSelf)(this, rect, rules[1], 'bold-in-header', s);
138
- e.suggestions = [(0, lint_1.fixByRemove)(e)];
140
+ if (computeEditInfo) {
141
+ e.suggestions = [(0, lint_1.fixByRemove)(e)];
142
+ }
139
143
  errors.push(e);
140
144
  }
141
145
  return errors;
@@ -97,7 +97,7 @@ let ParamTagToken = (() => {
97
97
  /** @private */
98
98
  lint(start = this.getAbsoluteIndex()) {
99
99
  LINT: { // eslint-disable-line no-unused-labels
100
- const rule = 'no-ignored', s = index_1.default.lintConfig.getSeverity(rule, this.name);
100
+ const rule = 'no-ignored', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, this.name);
101
101
  if (!s) {
102
102
  return [];
103
103
  }
@@ -113,7 +113,9 @@ let ParamTagToken = (() => {
113
113
  const i = grandChildren.findIndex(({ type }) => type !== 'text'), str = grandChildren.slice(0, i === -1 ? undefined : i).map(String).join('');
114
114
  if (str && !(i === -1 ? /^[a-z]+(?:\[\])?\s*=/iu : /^[a-z]+(?:\[\])?\s*(?:=|$)/iu).test(str)) {
115
115
  const e = (0, lint_1.generateForChild)(child, rect, rule, msg, s);
116
- e.suggestions = [(0, lint_1.fixByRemove)(e)];
116
+ if (lintConfig.computeEditInfo) {
117
+ e.suggestions = [(0, lint_1.fixByRemove)(e)];
118
+ }
117
119
  errors.push(e);
118
120
  }
119
121
  else {
@@ -178,7 +178,7 @@ let ParameterToken = (() => {
178
178
  /** @private */
179
179
  lint(start = this.getAbsoluteIndex(), re) {
180
180
  LINT: { // eslint-disable-line no-unused-labels
181
- const errors = super.lint(start, re), rule = 'unescaped', s = index_1.default.lintConfig.getSeverity(rule);
181
+ const errors = super.lint(start, re), rule = 'unescaped', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule);
182
182
  if (s) {
183
183
  const { firstChild } = this, link = linkRegex.exec(firstChild.text())?.[0];
184
184
  try {
@@ -189,7 +189,9 @@ let ParameterToken = (() => {
189
189
  e.startCol = e.endCol;
190
190
  e.endIndex++;
191
191
  e.endCol++;
192
- e.fix = (0, lint_1.fixByEscape)(e.startIndex, '{{=}}');
192
+ if (lintConfig.computeEditInfo || lintConfig.fix) {
193
+ e.fix = (0, lint_1.fixByEscape)(e.startIndex, '{{=}}');
194
+ }
193
195
  errors.push(e);
194
196
  }
195
197
  }
@@ -219,7 +219,7 @@ let TdToken = (() => {
219
219
  /** @private */
220
220
  lint(start = this.getAbsoluteIndex(), re) {
221
221
  LINT: { // eslint-disable-line no-unused-labels
222
- const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start + this.getRelativeIndex(this.length - 1)), rule = 'pipe-like', severities = ['td', 'double'].map(key => index_1.default.lintConfig.getSeverity(rule, key));
222
+ const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start + this.getRelativeIndex(this.length - 1)), rule = 'pipe-like', { lintConfig } = index_1.default, { computeEditInfo, fix } = lintConfig, severities = ['td', 'double'].map(key => lintConfig.getSeverity(rule, key));
223
223
  for (const child of this.lastChild.childNodes) {
224
224
  if (child.type === 'text') {
225
225
  const { data } = child;
@@ -227,12 +227,14 @@ let TdToken = (() => {
227
227
  const double = data.includes('||'), s = severities[double ? 1 : 0];
228
228
  if (s) {
229
229
  const e = (0, lint_1.generateForChild)(child, rect, rule, 'pipe-in-table', s);
230
- if (double) {
231
- const syntax = { caption: '|+', td: '|', th: '!' }[this.subtype];
232
- e.fix = (0, lint_1.fixBy)(e, 'newline', data.replace(/\|\|/gu, `\n${syntax}`));
233
- }
234
- else {
235
- e.suggestions = [(0, lint_1.fixByPipe)(e.startIndex, data)];
230
+ if (computeEditInfo || fix) {
231
+ if (double) {
232
+ const syntax = { caption: '|+', td: '|', th: '!' }[this.subtype];
233
+ e.fix = (0, lint_1.fixBy)(e, 'newline', data.replace(/\|\|/gu, `\n${syntax}`));
234
+ }
235
+ else if (computeEditInfo) {
236
+ e.suggestions = [(0, lint_1.fixByPipe)(e.startIndex, data)];
237
+ }
236
238
  }
237
239
  errors.push(e);
238
240
  }
@@ -199,14 +199,14 @@ let ExtToken = (() => {
199
199
  /** @private */
200
200
  lint(start = this.getAbsoluteIndex(), re) {
201
201
  LINT: { // eslint-disable-line no-unused-labels
202
- const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start);
202
+ const errors = super.lint(start, re), { lintConfig } = index_1.default, rect = new rect_1.BoundingRect(this, start);
203
203
  if (this.name !== 'nowiki') {
204
- const s = this.inHtmlAttrs(), rule = 'parsing-order', severity = s && index_1.default.lintConfig.getSeverity(rule, s === 2 ? 'ext' : 'templateInTable');
204
+ const s = this.inHtmlAttrs(), rule = 'parsing-order', severity = s && lintConfig.getSeverity(rule, s === 2 ? 'ext' : 'templateInTable');
205
205
  if (severity) {
206
206
  errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'ext-in-html', severity));
207
207
  }
208
208
  }
209
- const rule = 'var-anchor', s = index_1.default.lintConfig.getSeverity(rule, 'ref');
209
+ const rule = 'var-anchor', s = lintConfig.getSeverity(rule, 'ref');
210
210
  if (s && this.name === 'ref' && this.closest('heading-title')) {
211
211
  errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'variable-anchor', s));
212
212
  }