wikiparser-node 1.29.2 → 1.31.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 (107) hide show
  1. package/README.md +8 -4
  2. package/bundle/bundle-es8.min.js +29 -26
  3. package/bundle/bundle-lsp.min.js +34 -31
  4. package/bundle/bundle.min.js +22 -22
  5. package/dist/addon/magicWords.js +642 -40
  6. package/dist/addon/token.js +99 -111
  7. package/dist/addon/transclude.js +2 -2
  8. package/dist/base.d.mts +4 -3
  9. package/dist/base.d.ts +4 -3
  10. package/dist/base.js +3 -0
  11. package/dist/base.mjs +3 -0
  12. package/dist/bin/config.js +1 -1
  13. package/dist/index.d.ts +11 -1
  14. package/dist/index.js +47 -15
  15. package/dist/internal.d.ts +2 -1
  16. package/dist/lib/attributes.js +0 -1
  17. package/dist/lib/document.js +2 -2
  18. package/dist/lib/element.d.ts +1 -1
  19. package/dist/lib/element.js +9 -7
  20. package/dist/lib/lintConfig.js +12 -1
  21. package/dist/lib/lsp.d.ts +0 -1
  22. package/dist/lib/lsp.js +2 -5
  23. package/dist/lib/node.js +7 -9
  24. package/dist/lib/redirectMap.js +1 -1
  25. package/dist/lib/text.js +68 -22
  26. package/dist/lib/title.js +1 -1
  27. package/dist/mixin/attributesParent.d.ts +0 -1
  28. package/dist/mixin/attributesParent.js +2 -4
  29. package/dist/mixin/elementLike.js +2 -4
  30. package/dist/mixin/fixed.js +0 -2
  31. package/dist/mixin/gapped.js +0 -2
  32. package/dist/mixin/hidden.js +1 -3
  33. package/dist/mixin/noEscape.js +1 -3
  34. package/dist/mixin/nodeLike.js +2 -4
  35. package/dist/mixin/padded.js +5 -9
  36. package/dist/mixin/singleLine.js +0 -2
  37. package/dist/mixin/sol.js +0 -2
  38. package/dist/mixin/syntax.js +0 -2
  39. package/dist/parser/commentAndExt.js +1 -1
  40. package/dist/parser/hrAndDoubleUnderscore.js +11 -9
  41. package/dist/parser/quotes.js +20 -8
  42. package/dist/parser/table.js +1 -2
  43. package/dist/src/arg.js +10 -5
  44. package/dist/src/atom.js +2 -0
  45. package/dist/src/attribute.js +12 -12
  46. package/dist/src/attributes.js +6 -5
  47. package/dist/src/commented.js +0 -1
  48. package/dist/src/converterFlags.js +1 -1
  49. package/dist/src/converterRule.js +1 -2
  50. package/dist/src/extLink.js +2 -2
  51. package/dist/src/heading.d.ts +8 -0
  52. package/dist/src/heading.js +25 -2
  53. package/dist/src/imageParameter.js +6 -7
  54. package/dist/src/index.d.ts +0 -2
  55. package/dist/src/index.js +5 -9
  56. package/dist/src/link/base.js +13 -6
  57. package/dist/src/link/category.d.ts +1 -1
  58. package/dist/src/link/category.js +5 -3
  59. package/dist/src/link/file.js +9 -9
  60. package/dist/src/link/galleryImage.d.ts +0 -2
  61. package/dist/src/link/galleryImage.js +2 -4
  62. package/dist/src/link/index.js +4 -4
  63. package/dist/src/link/redirectTarget.js +1 -1
  64. package/dist/src/magicLink.js +3 -3
  65. package/dist/src/multiLine/gallery.js +5 -5
  66. package/dist/src/multiLine/imagemap.js +1 -1
  67. package/dist/src/multiLine/paramTag.js +1 -1
  68. package/dist/src/nested.js +1 -1
  69. package/dist/src/nowiki/comment.js +1 -1
  70. package/dist/src/nowiki/dd.d.ts +3 -0
  71. package/dist/src/nowiki/doubleUnderscore.d.ts +3 -0
  72. package/dist/src/nowiki/hr.d.ts +3 -0
  73. package/dist/src/nowiki/index.js +3 -3
  74. package/dist/src/nowiki/list.d.ts +5 -0
  75. package/dist/src/nowiki/list.js +32 -0
  76. package/dist/src/nowiki/listBase.js +2 -2
  77. package/dist/src/nowiki/noinclude.d.ts +2 -1
  78. package/dist/src/nowiki/noinclude.js +26 -1
  79. package/dist/src/nowiki/quote.d.ts +21 -0
  80. package/dist/src/nowiki/quote.js +61 -4
  81. package/dist/src/paramLine.js +2 -0
  82. package/dist/src/parameter.js +3 -3
  83. package/dist/src/pre.js +1 -1
  84. package/dist/src/redirect.js +1 -1
  85. package/dist/src/syntax.js +1 -1
  86. package/dist/src/table/base.js +2 -3
  87. package/dist/src/table/index.d.ts +1 -5
  88. package/dist/src/table/index.js +8 -10
  89. package/dist/src/table/td.js +11 -12
  90. package/dist/src/table/trBase.js +2 -4
  91. package/dist/src/tag/html.js +4 -5
  92. package/dist/src/tag/index.js +9 -8
  93. package/dist/src/tagPair/ext.js +7 -6
  94. package/dist/src/tagPair/include.js +1 -1
  95. package/dist/src/tagPair/translate.d.ts +1 -0
  96. package/dist/src/tagPair/translate.js +8 -1
  97. package/dist/src/transclude.d.ts +6 -6
  98. package/dist/src/transclude.js +25 -18
  99. package/dist/util/constants.js +4 -2
  100. package/dist/util/html.js +11 -5
  101. package/dist/util/string.js +22 -10
  102. package/extensions/dist/base.js +3 -3
  103. package/extensions/editor.css +1 -1
  104. package/i18n/en.json +3 -0
  105. package/i18n/zh-hans.json +3 -0
  106. package/i18n/zh-hant.json +3 -0
  107. package/package.json +34 -29
@@ -87,13 +87,12 @@ let LinkBaseToken = (() => {
87
87
  /* NOT FOR BROWSER END */
88
88
  /** full link / 完整链接 */
89
89
  get link() {
90
- // eslint-disable-next-line no-unused-labels
91
90
  LSP: return this.#title;
92
91
  }
93
92
  /* PRINT ONLY */
94
93
  /** 片段标识符 */
95
94
  get fragment() {
96
- LSP: return this.#title.fragment; // eslint-disable-line no-unused-labels
95
+ LSP: return this.#title.fragment;
97
96
  }
98
97
  /* PRINT ONLY END */
99
98
  /* NOT FOR BROWSER */
@@ -214,7 +213,7 @@ let LinkBaseToken = (() => {
214
213
  }
215
214
  /** @private */
216
215
  lint(start = this.getAbsoluteIndex(), re) {
217
- LINT: { // eslint-disable-line no-unused-labels
216
+ LINT: {
218
217
  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
218
  let rule = 'unknown-page', s = lintConfig.getSeverity(rule);
220
219
  if (s && target.childNodes.some(({ type: t }) => t === 'template')) {
@@ -267,7 +266,7 @@ let LinkBaseToken = (() => {
267
266
  }
268
267
  /** @private */
269
268
  json(_, start = this.getAbsoluteIndex()) {
270
- LSP: { // eslint-disable-line no-unused-labels
269
+ LSP: {
271
270
  const json = super.json(undefined, start), { type, fragment } = this;
272
271
  if (fragment !== undefined && (type === 'link' || type === 'redirect-target')) {
273
272
  json['fragment'] = fragment;
@@ -336,8 +335,16 @@ let LinkBaseToken = (() => {
336
335
  /** @private */
337
336
  toHtmlInternal(opt) {
338
337
  if (this.is('link') || this.is('redirect-target')) {
339
- const { link, length, lastChild, type } = this, title = link.getTitleAttr();
340
- return `<a${link.interwiki && ' class="extiw"'} href="${link.getUrl()}"${title && ` title="${title}"`}>${type === 'link' && length > 1
338
+ const { link, length, lastChild, type, pageName } = this;
339
+ let attr;
340
+ if (type === 'link' && link.title === pageName && !link.fragment) {
341
+ attr = 'class="mw-selflink"';
342
+ }
343
+ else {
344
+ const title = link.getTitleAttr();
345
+ attr = `${link.interwiki && 'class="extiw" '}href="${link.getUrl()}"${title && ` title="${title}"`}`;
346
+ }
347
+ return `<a ${attr}>${type === 'link' && length > 1
341
348
  ? lastChild.toHtmlInternal({
342
349
  ...opt,
343
350
  nowrap: true,
@@ -1,7 +1,7 @@
1
1
  import { LinkBaseToken } from './base';
2
2
  import type { Title } from '../../lib/title';
3
- import type { AST } from '../../base';
4
3
  import type { Token, AtomToken } from '../../internal';
4
+ import type { AST } from '../../base';
5
5
  /**
6
6
  * category
7
7
  *
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CategoryToken = void 0;
4
- const string_1 = require("../../util/string");
5
4
  const base_1 = require("./base");
5
+ /* PRINT ONLY */
6
+ const string_1 = require("../../util/string");
7
+ /* PRINT ONLY END */
6
8
  /* NOT FOR BROWSER */
7
9
  const constants_1 = require("../../util/constants");
8
10
  /* NOT FOR BROWSER END */
@@ -20,7 +22,7 @@ class CategoryToken extends base_1.LinkBaseToken {
20
22
  /* PRINT ONLY */
21
23
  /** sort key / 分类排序关键字 */
22
24
  get sortkey() {
23
- LSP: { // eslint-disable-line no-unused-labels
25
+ LSP: {
24
26
  const { childNodes: [, child] } = this;
25
27
  return child && (0, string_1.decodeHtml)(child.text());
26
28
  }
@@ -33,7 +35,7 @@ class CategoryToken extends base_1.LinkBaseToken {
33
35
  /* NOT FOR BROWSER END */
34
36
  /** @private */
35
37
  json(_, start = this.getAbsoluteIndex()) {
36
- LSP: { // eslint-disable-line no-unused-labels
38
+ LSP: {
37
39
  const json = super.json(undefined, start), { sortkey } = this;
38
40
  if (sortkey) {
39
41
  json['sortkey'] = sortkey;
@@ -113,7 +113,7 @@ let FileToken = (() => {
113
113
  * @since v1.5.3
114
114
  */
115
115
  get extension() {
116
- LSP: return this.getAttribute('title').extension; // eslint-disable-line no-unused-labels
116
+ LSP: return this.getAttribute('title').extension;
117
117
  }
118
118
  /* NOT FOR BROWSER */
119
119
  /** image link / 图片链接 */
@@ -181,14 +181,14 @@ let FileToken = (() => {
181
181
  }
182
182
  /** @private */
183
183
  lint(start = this.getAbsoluteIndex(), re) {
184
- LINT: { // eslint-disable-line no-unused-labels
184
+ LINT: {
185
185
  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, { ns, extension,
186
186
  /* NOT FOR BROWSER */
187
187
  interwiki, } = this.getAttribute('title'), { firstChild } = this;
188
188
  let rule = 'nested-link', s = lintConfig.getSeverity(rule, 'file');
189
189
  if (s
190
190
  && imageParameter_1.extensions.has(extension)
191
- && this.closest('ext-link-text')
191
+ && this.isInside('ext-link-text')
192
192
  && this.getValue('link')?.trim() !== '') {
193
193
  const e = (0, lint_1.generateForSelf)(this, rect, rule, 'link-in-extlink', s);
194
194
  if (computeEditInfo || fix) {
@@ -289,7 +289,7 @@ let FileToken = (() => {
289
289
  * 获取所有图片参数节点
290
290
  */
291
291
  getAllArgs() {
292
- LINT: return this.childNodes.slice(1); // eslint-disable-line no-unused-labels
292
+ LINT: return this.childNodes.slice(1);
293
293
  }
294
294
  /**
295
295
  * Get image parameters with the specified name
@@ -298,7 +298,7 @@ let FileToken = (() => {
298
298
  * @param key parameter name / 参数名
299
299
  */
300
300
  getArgs(key) {
301
- LINT: return this.getAllArgs().filter(({ name }) => key === name); // eslint-disable-line no-unused-labels
301
+ LINT: return this.getAllArgs().filter(({ name }) => key === name);
302
302
  }
303
303
  /**
304
304
  * Get the effective image parameter with the specified name
@@ -307,7 +307,7 @@ let FileToken = (() => {
307
307
  * @param key parameter name / 参数名
308
308
  */
309
309
  getArg(key) {
310
- LINT: { // eslint-disable-line no-unused-labels
310
+ LINT: {
311
311
  const args = this.getArgs(key);
312
312
  return args[key === 'manualthumb' ? 0 : args.length - 1];
313
313
  }
@@ -319,11 +319,11 @@ let FileToken = (() => {
319
319
  * @param key parameter name / 参数名
320
320
  */
321
321
  getValue(key) {
322
- LINT: return this.getArg(key)?.getValue(); // eslint-disable-line no-unused-labels
322
+ LINT: return this.getArg(key)?.getValue();
323
323
  }
324
324
  /** @private */
325
325
  json(_, start = this.getAbsoluteIndex()) {
326
- LSP: { // eslint-disable-line no-unused-labels
326
+ LSP: {
327
327
  const json = super.json(undefined, start), { extension } = this;
328
328
  if (extension) {
329
329
  json['extension'] = extension;
@@ -509,7 +509,7 @@ let FileToken = (() => {
509
509
  ? `<a${href && ` href="${href}"`}${hasLink ? '' : ' class="mw-file-description"'}${titleAttr}${typeof link === 'string' ? ' rel="nofollow"' : ''}>${img}</a>`
510
510
  : `<span${titleAttr}>${img}</span>`;
511
511
  if (type !== 'gallery-image') {
512
- return horiz || vert || visibleCaption
512
+ return horiz || visibleCaption
513
513
  ? `<figure${classAttr} typeof="mw:File${fr ? `/${manual ? 'Thumb' : frame.get(fr)}` : ''}">${a}<figcaption>${caption}</figcaption></figure>`
514
514
  : `<span${classAttr}>${a}</span>`;
515
515
  }
@@ -22,8 +22,6 @@ export declare abstract class GalleryImageToken extends FileToken {
22
22
  * @override
23
23
  * @param child node to be inserted / 待插入的子节点
24
24
  * @param i position to be inserted at / 插入位置
25
- * @throws `RangeError` 不可插入多余子节点
26
- * @throws `TypeError` 不可插入文本节点
27
25
  */
28
26
  insertAt<T extends AtomToken | ImageParameterToken>(child: T, i?: number): T;
29
27
  cloneNode(): this;
@@ -100,7 +100,7 @@ let GalleryImageToken = (() => {
100
100
  }
101
101
  accum.splice(length, 1);
102
102
  }
103
- super(link, token?.toString(), config, accum);
103
+ super(link, token?.firstChild.toString(), config, accum);
104
104
  this.setAttribute('bracket', false);
105
105
  this.privateType = `${type}-image`;
106
106
  /* PRINT ONLY */
@@ -121,7 +121,7 @@ let GalleryImageToken = (() => {
121
121
  }
122
122
  /** @private */
123
123
  lint(start = this.getAbsoluteIndex(), re) {
124
- LINT: { // eslint-disable-line no-unused-labels
124
+ LINT: {
125
125
  const errors = super.lint(start, re), rule = 'invalid-gallery', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, 'image');
126
126
  if (s && this.#lint()) {
127
127
  const e = (0, lint_1.generateForSelf)(this, { start }, rule, 'invalid-gallery', s);
@@ -144,8 +144,6 @@ let GalleryImageToken = (() => {
144
144
  * @override
145
145
  * @param child node to be inserted / 待插入的子节点
146
146
  * @param i position to be inserted at / 插入位置
147
- * @throws `RangeError` 不可插入多余子节点
148
- * @throws `TypeError` 不可插入文本节点
149
147
  */
150
148
  insertAt(child, i) {
151
149
  if (this.type === 'gallery-image'
@@ -25,7 +25,7 @@ class LinkToken extends base_1.LinkBaseToken {
25
25
  }
26
26
  /** link text / 链接显示文字 */
27
27
  get innerText() {
28
- LINT: return this.length > 1 // eslint-disable-line no-unused-labels
28
+ LINT: return this.length > 1
29
29
  ? this.lastChild.text()
30
30
  : (0, common_1.rawurldecode)(this.firstChild.text().replace(/^\s*:?/u, ''));
31
31
  }
@@ -35,7 +35,7 @@ class LinkToken extends base_1.LinkBaseToken {
35
35
  }
36
36
  /** whether to be a self link / 是否链接到自身 */
37
37
  get selfLink() {
38
- const { link: { title, fragment } } = this;
38
+ const { title, fragment } = this.link;
39
39
  return !title && Boolean(fragment);
40
40
  }
41
41
  set selfLink(selfLink) {
@@ -46,9 +46,9 @@ class LinkToken extends base_1.LinkBaseToken {
46
46
  /* NOT FOR BROWSER END */
47
47
  /** @private */
48
48
  lint(start = this.getAbsoluteIndex(), re) {
49
- LINT: { // eslint-disable-line no-unused-labels
49
+ LINT: {
50
50
  const errors = super.lint(start, re), rule = 'nested-link', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule);
51
- if (s && this.closest('ext-link-text')) {
51
+ if (s && this.isInside('ext-link-text')) {
52
52
  const e = (0, lint_1.generateForSelf)(this, { start }, rule, 'link-in-extlink', s);
53
53
  if (lintConfig.computeEditInfo || lintConfig.fix) {
54
54
  e.fix = (0, lint_1.fixBy)(e, 'delink', this.innerText);
@@ -54,7 +54,7 @@ class RedirectTargetToken extends base_1.LinkBaseToken {
54
54
  }
55
55
  /** @private */
56
56
  lint(start = this.getAbsoluteIndex()) {
57
- LINT: { // eslint-disable-line no-unused-labels
57
+ LINT: {
58
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);
@@ -167,7 +167,7 @@ let MagicLinkToken = (() => {
167
167
  if (this.type === 'magic-link') {
168
168
  const { link } = this;
169
169
  if (link.startsWith('ISBN')) {
170
- // eslint-disable-next-line unicorn/no-useless-spread, @typescript-eslint/no-misused-spread
170
+ // eslint-disable-next-line unicorn/no-useless-spread
171
171
  const digits = [...link.slice(5)].map(s => s === 'X' ? 10 : Number(s));
172
172
  return digits.length === 10
173
173
  ? digits.reduce((sum, d, i) => sum + d * (10 - i), 0) % 11 !== 0
@@ -179,7 +179,7 @@ let MagicLinkToken = (() => {
179
179
  }
180
180
  /** @private */
181
181
  lint(start = this.getAbsoluteIndex(), re) {
182
- LINT: { // eslint-disable-line no-unused-labels
182
+ LINT: {
183
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
185
  const rule = 'invalid-isbn', s = lintConfig.getSeverity(rule);
@@ -226,7 +226,7 @@ let MagicLinkToken = (() => {
226
226
  * @param articlePath article path / 条目路径
227
227
  */
228
228
  getUrl(articlePath) {
229
- LSP: { // eslint-disable-line no-unused-labels
229
+ LSP: {
230
230
  const { type } = this;
231
231
  let { link } = this;
232
232
  if (type === 'magic-link') {
@@ -83,7 +83,7 @@ let GalleryToken = (() => {
83
83
  * @since v1.12.5
84
84
  */
85
85
  get widths() {
86
- LSP: return this.#getSize('widths'); // eslint-disable-line no-unused-labels
86
+ LSP: return this.#getSize('widths');
87
87
  }
88
88
  /**
89
89
  * image heights
@@ -92,7 +92,7 @@ let GalleryToken = (() => {
92
92
  * @since v1.12.5
93
93
  */
94
94
  get heights() {
95
- LSP: return this.#getSize('heights'); // eslint-disable-line no-unused-labels
95
+ LSP: return this.#getSize('heights');
96
96
  }
97
97
  /* PRINT ONLY END */
98
98
  /** @param inner 标签内部wikitext */
@@ -128,7 +128,7 @@ let GalleryToken = (() => {
128
128
  }
129
129
  /** @private */
130
130
  lint(start = this.getAbsoluteIndex(), re) {
131
- LINT: { // eslint-disable-line no-unused-labels
131
+ LINT: {
132
132
  const { top, left } = this.getRootNode().posFromIndex(start), errors = [], rule = 'no-ignored', { lintConfig } = index_1.default, s = ['Image', 'NoImage', 'Comment'].map(k => lintConfig.getSeverity(rule, `gallery${k}`));
133
133
  for (let i = 0; i < this.length; i++) {
134
134
  const child = this.childNodes[i], str = child.toString(), { length } = str, trimmed = str.trim(), { type } = child, startLine = top + i, startCol = i ? 0 : left;
@@ -179,14 +179,14 @@ let GalleryToken = (() => {
179
179
  * @param key `widths` 或 `heights`
180
180
  */
181
181
  #getSize(key) {
182
- LSP: { // eslint-disable-line no-unused-labels
182
+ LSP: {
183
183
  const widths = this.parentNode?.getAttr(key), mt = typeof widths === 'string' && /^(\d+)\s*(?:px)?$/u.exec(widths)?.[1];
184
184
  return mt && Number(mt) || 120;
185
185
  }
186
186
  }
187
187
  /** @private */
188
188
  json(_, start = this.getAbsoluteIndex()) {
189
- LSP: { // eslint-disable-line no-unused-labels
189
+ LSP: {
190
190
  const json = super.json(undefined, start);
191
191
  Object.assign(json, { widths: this.widths, heights: this.heights });
192
192
  return json;
@@ -135,7 +135,7 @@ let ImagemapToken = (() => {
135
135
  }
136
136
  /** @private */
137
137
  lint(start = this.getAbsoluteIndex(), re) {
138
- LINT: { // eslint-disable-line no-unused-labels
138
+ LINT: {
139
139
  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');
140
140
  if (s) {
141
141
  if (image) {
@@ -83,7 +83,7 @@ let ParamTagToken = (() => {
83
83
  }
84
84
  /** @private */
85
85
  lint(start = this.getAbsoluteIndex()) {
86
- LINT: { // eslint-disable-line no-unused-labels
86
+ LINT: {
87
87
  const rule = 'no-ignored', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, this.name);
88
88
  if (!s) {
89
89
  return [];
@@ -110,7 +110,7 @@ let NestedToken = (() => {
110
110
  }
111
111
  /** @private */
112
112
  lint(start = this.getAbsoluteIndex(), re) {
113
- LINT: { // eslint-disable-line no-unused-labels
113
+ LINT: {
114
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;
@@ -87,7 +87,7 @@ let CommentToken = (() => {
87
87
  }
88
88
  /** @private */
89
89
  lint(start = this.getAbsoluteIndex()) {
90
- LINT: { // eslint-disable-line no-unused-labels
90
+ LINT: {
91
91
  if (this.closed) {
92
92
  return [];
93
93
  }
@@ -1,4 +1,7 @@
1
1
  import { ListBaseToken } from './listBase';
2
+ import type { SyntaxBase } from '../../mixin/syntax';
3
+ export interface DdToken extends SyntaxBase {
4
+ }
2
5
  /** `:` */
3
6
  export declare abstract class DdToken extends ListBaseToken {
4
7
  get type(): 'dd';
@@ -1,6 +1,9 @@
1
1
  import { NowikiBaseToken } from './base';
2
2
  import type { Config } from '../../base';
3
3
  import type { Token } from '../../internal';
4
+ import type { SyntaxBase } from '../../mixin/syntax';
5
+ export interface DoubleUnderscoreToken extends SyntaxBase {
6
+ }
4
7
  /**
5
8
  * behavior switch
6
9
  *
@@ -1,4 +1,7 @@
1
1
  import { NowikiBaseToken } from './base';
2
+ import type { SyntaxBase } from '../../mixin/syntax';
3
+ export interface HrToken extends SyntaxBase {
4
+ }
2
5
  /** `<hr>` */
3
6
  export declare abstract class HrToken extends NowikiBaseToken {
4
7
  get type(): 'hr';
@@ -43,7 +43,7 @@ class NowikiToken extends base_1.NowikiBaseToken {
43
43
  }
44
44
  /** @private */
45
45
  lint(start = this.getAbsoluteIndex()) {
46
- LINT: { // eslint-disable-line no-unused-labels
46
+ LINT: {
47
47
  const { name,
48
48
  /* NOT FOR BROWSER ONLY */
49
49
  innerText, previousSibling, } = this, { lintConfig } = index_1.default;
@@ -57,7 +57,7 @@ class NowikiToken extends base_1.NowikiBaseToken {
57
57
  }
58
58
  const errors = super.lint(start, getLintRegex(name));
59
59
  /* NOT FOR BROWSER ONLY */
60
- NPM: { // eslint-disable-line no-unused-labels
60
+ NPM: {
61
61
  rule = 'invalid-math';
62
62
  s = lintConfig.getSeverity(rule);
63
63
  if (s && document_1.texvcjs && constants_1.mathTags.has(name)) {
@@ -87,7 +87,7 @@ class NowikiToken extends base_1.NowikiBaseToken {
87
87
  if (result.status !== '+') {
88
88
  const e = (0, lint_1.generateForSelf)(this, { start }, rule, 'chem-required', s);
89
89
  if (result.status !== 'C') {
90
- const { error: { message, location } } = result, [endIndex, endLine, endCol] = updateLocation(e, location.end, n);
90
+ const { message, location } = result.error, [endIndex, endLine, endCol] = updateLocation(e, location.end, n);
91
91
  [e.startIndex, e.startLine, e.startCol] = updateLocation(e, location.start, n);
92
92
  Object.assign(e, { endIndex, endLine, endCol, message });
93
93
  }
@@ -1,4 +1,8 @@
1
1
  import { ListBaseToken } from './listBase';
2
+ import type { LintError } from '../../base';
3
+ import type { SyntaxBase } from '../../mixin/syntax';
4
+ export interface ListToken extends SyntaxBase {
5
+ }
2
6
  /**
3
7
  * `;:*#` at the start of a line
4
8
  *
@@ -6,4 +10,5 @@ import { ListBaseToken } from './listBase';
6
10
  */
7
11
  export declare abstract class ListToken extends ListBaseToken {
8
12
  get type(): 'list';
13
+ lint(start?: number): LintError[];
9
14
  }
@@ -33,14 +33,20 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
33
33
  }
34
34
  return useValue ? value : void 0;
35
35
  };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
36
39
  Object.defineProperty(exports, "__esModule", { value: true });
37
40
  exports.ListToken = void 0;
41
+ const lint_1 = require("../../util/lint");
42
+ const index_1 = __importDefault(require("../../index"));
38
43
  const listBase_1 = require("./listBase");
39
44
  /* NOT FOR BROWSER */
40
45
  const constants_1 = require("../../util/constants");
41
46
  const sol_1 = require("../../mixin/sol");
42
47
  const syntax_1 = require("../../mixin/syntax");
43
48
  /* NOT FOR BROWSER END */
49
+ const linkTypes = new Set(['link', 'category', 'file']);
44
50
  /**
45
51
  * `;:*#` at the start of a line
46
52
  *
@@ -64,6 +70,32 @@ let ListToken = (() => {
64
70
  get type() {
65
71
  return 'list';
66
72
  }
73
+ lint(start = this.getAbsoluteIndex()) {
74
+ LINT: {
75
+ const rule = 'syntax-like', s = index_1.default.lintConfig.getSeverity(rule, 'redirect'), { innerText } = this;
76
+ if (s && innerText === '#') {
77
+ let { nextSibling } = this;
78
+ /* NOT FOR BROWSER */
79
+ if (nextSibling?.is('list-range')) {
80
+ nextSibling = nextSibling.firstChild;
81
+ }
82
+ /* NOT FOR BROWSER END */
83
+ if (nextSibling?.type === 'text' && linkTypes.has(nextSibling.nextSibling?.type)) {
84
+ /^redirect\s*(?::\s*)?$/iu; // eslint-disable-line @typescript-eslint/no-unused-expressions
85
+ const re = new RegExp(String.raw `^(?:${this.getAttribute('config').redirection.join('|')})\s*(?::\s*)?$`, 'iu');
86
+ if (re.test(`#${nextSibling.data}`)) {
87
+ const e = (0, lint_1.generateForSelf)(nextSibling, { start: start + 1 }, rule, 'redirect-like', s);
88
+ e.startIndex--;
89
+ e.startCol--;
90
+ e.endIndex += 2;
91
+ e.endCol += 2;
92
+ return [e];
93
+ }
94
+ }
95
+ }
96
+ return [];
97
+ }
98
+ }
67
99
  };
68
100
  return ListToken = _classThis;
69
101
  })();
@@ -17,7 +17,7 @@ class ListBaseToken extends base_1.NowikiBaseToken {
17
17
  * @since v1.16.5
18
18
  */
19
19
  get indent() {
20
- LSP: return this.innerText.split(':').length - 1; // eslint-disable-line no-unused-labels
20
+ LSP: return this.innerText.split(':').length - 1;
21
21
  }
22
22
  /* PRINT ONLY END */
23
23
  /* NOT FOR BROWSER */
@@ -47,7 +47,7 @@ class ListBaseToken extends base_1.NowikiBaseToken {
47
47
  /* NOT FOR BROWSER END */
48
48
  /** @private */
49
49
  json(_, start = this.getAbsoluteIndex()) {
50
- LSP: { // eslint-disable-line no-unused-labels
50
+ LSP: {
51
51
  const json = super.json(undefined, start), { indent } = this;
52
52
  if (indent) {
53
53
  json['indent'] = indent;
@@ -1,5 +1,5 @@
1
1
  import { NowikiBaseToken } from './base';
2
- import type { Config } from '../../base';
2
+ import type { LintError, Config } from '../../base';
3
3
  import type { Token } from '../../internal';
4
4
  /**
5
5
  * `<noinclude>` or `</noinclude>` that allows no modification
@@ -11,6 +11,7 @@ export declare abstract class NoincludeToken extends NowikiBaseToken {
11
11
  get type(): 'noinclude';
12
12
  /** @param fixed 是否不可更改 */
13
13
  constructor(wikitext: string, config?: Config, accum?: Token[], fixed?: boolean);
14
+ lint(start?: number): LintError[];
14
15
  cloneNode(): this;
15
16
  setText(str: string): string;
16
17
  }
@@ -33,9 +33,14 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
33
33
  }
34
34
  return useValue ? value : void 0;
35
35
  };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
36
39
  Object.defineProperty(exports, "__esModule", { value: true });
37
40
  exports.NoincludeToken = void 0;
41
+ const lint_1 = require("../../util/lint");
38
42
  const hidden_1 = require("../../mixin/hidden");
43
+ const index_1 = __importDefault(require("../../index"));
39
44
  const base_1 = require("./base");
40
45
  /* NOT FOR BROWSER */
41
46
  const constants_1 = require("../../util/constants");
@@ -47,7 +52,7 @@ const debug_1 = require("../../util/debug");
47
52
  * `<noinclude>`或`</noinclude>`,不可进行任何更改
48
53
  */
49
54
  let NoincludeToken = (() => {
50
- let _classDecorators = [(0, hidden_1.hiddenToken)()];
55
+ let _classDecorators = [(0, hidden_1.hiddenToken)(false)];
51
56
  let _classDescriptor;
52
57
  let _classExtraInitializers = [];
53
58
  let _classThis;
@@ -78,6 +83,26 @@ let NoincludeToken = (() => {
78
83
  toString(skip) {
79
84
  return skip ? '' : super.toString();
80
85
  }
86
+ lint(start = this.getAbsoluteIndex()) {
87
+ LINT: {
88
+ const { lintConfig } = index_1.default, rule = 'no-ignored', s = lintConfig.getSeverity(rule, 'include');
89
+ if (s) {
90
+ const { innerText } = this, mt = /^<(noinclude|includeonly|onlyinclude)\s+(?:[^\s>/]|\/(?!>))[^>]*>$/iu.exec(innerText);
91
+ if (mt) {
92
+ const e = (0, lint_1.generateForSelf)(this, { start }, rule, 'useless-attribute', s), { computeEditInfo } = lintConfig, before = mt[1].length + 1, after = innerText.endsWith('/>') ? 2 : 1;
93
+ e.startIndex += before;
94
+ e.startCol += before;
95
+ e.endIndex -= after;
96
+ e.endCol -= after;
97
+ if (computeEditInfo) {
98
+ e.suggestions = [(0, lint_1.fixByRemove)(e)];
99
+ }
100
+ return [e];
101
+ }
102
+ }
103
+ return [];
104
+ }
105
+ }
81
106
  /* NOT FOR BROWSER */
82
107
  cloneNode() {
83
108
  return debug_1.Shadow.run(() => {
@@ -2,6 +2,10 @@ import { NowikiBaseToken } from './base';
2
2
  import type { LintError, Config, AST } from '../../base';
3
3
  import type { Font } from '../../lib/node';
4
4
  import type { Token } from '../../internal';
5
+ import type { AstRange } from '../../lib/range';
6
+ import type { SyntaxBase } from '../../mixin/syntax';
7
+ export interface QuoteToken extends SyntaxBase {
8
+ }
5
9
  /**
6
10
  * `''` and `'''`
7
11
  *
@@ -23,4 +27,21 @@ export declare abstract class QuoteToken extends NowikiBaseToken {
23
27
  /** @param closing 是否闭合 */
24
28
  constructor(wikitext: string, closing: Font, config?: Config, accum?: Token[]);
25
29
  cloneNode(): this;
30
+ setAttribute<T extends string>(key: T, value: TokenAttribute<T>): void;
31
+ /**
32
+ * Find the matching apostrophes
33
+ *
34
+ * 搜索匹配的直引号
35
+ * @since v1.29.3
36
+ * @param type type of apostrophes to match / 匹配的直引号类型
37
+ * @throws `RangeError` ambiguous or wrong apostrophe type
38
+ */
39
+ findMatchingQuote(type?: 'bold' | 'italic'): this | undefined;
40
+ /**
41
+ * Try to get the range of bold/italic text
42
+ *
43
+ * 尝试获取粗体/斜体文本范围
44
+ * @param type type of apostrophes / 直引号类型
45
+ */
46
+ getRange(type?: 'bold' | 'italic'): AstRange | undefined;
26
47
  }