wikilint 2.9.0 → 2.9.2

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 (94) hide show
  1. package/dist/base.d.ts +2 -0
  2. package/dist/index.d.ts +2 -4
  3. package/dist/index.js +6 -6
  4. package/dist/lib/element.d.ts +0 -7
  5. package/dist/lib/element.js +2 -5
  6. package/dist/lib/node.js +1 -4
  7. package/dist/lib/rect.d.ts +18 -0
  8. package/dist/lib/rect.js +32 -0
  9. package/dist/lib/text.js +2 -9
  10. package/dist/mixin/attributesParent.js +2 -1
  11. package/dist/mixin/hidden.d.ts +2 -0
  12. package/dist/mixin/hidden.js +9 -4
  13. package/dist/parser/braces.js +19 -12
  14. package/dist/parser/commentAndExt.js +1 -8
  15. package/dist/parser/converter.js +2 -3
  16. package/dist/parser/externalLinks.js +1 -8
  17. package/dist/parser/hrAndDoubleUnderscore.js +1 -1
  18. package/dist/parser/html.js +1 -1
  19. package/dist/parser/links.js +1 -1
  20. package/dist/parser/magicLinks.js +6 -12
  21. package/dist/parser/redirect.js +1 -1
  22. package/dist/src/arg.d.ts +0 -2
  23. package/dist/src/arg.js +4 -3
  24. package/dist/src/atom.d.ts +2 -2
  25. package/dist/src/atom.js +3 -4
  26. package/dist/src/attribute.d.ts +0 -2
  27. package/dist/src/attribute.js +5 -16
  28. package/dist/src/attributes.js +8 -12
  29. package/dist/src/converter.d.ts +0 -2
  30. package/dist/src/converter.js +1 -1
  31. package/dist/src/converterFlags.d.ts +0 -2
  32. package/dist/src/converterFlags.js +4 -2
  33. package/dist/src/converterRule.d.ts +0 -2
  34. package/dist/src/converterRule.js +1 -1
  35. package/dist/src/extLink.d.ts +0 -2
  36. package/dist/src/extLink.js +1 -1
  37. package/dist/src/gallery.d.ts +0 -2
  38. package/dist/src/gallery.js +1 -1
  39. package/dist/src/heading.d.ts +0 -2
  40. package/dist/src/heading.js +3 -8
  41. package/dist/src/hidden.d.ts +1 -1
  42. package/dist/src/hidden.js +53 -3
  43. package/dist/src/html.d.ts +2 -5
  44. package/dist/src/html.js +14 -34
  45. package/dist/src/imageParameter.d.ts +0 -2
  46. package/dist/src/imageParameter.js +5 -4
  47. package/dist/src/imagemap.d.ts +0 -2
  48. package/dist/src/imagemap.js +4 -3
  49. package/dist/src/index.d.ts +0 -11
  50. package/dist/src/index.js +16 -25
  51. package/dist/src/link/base.d.ts +0 -2
  52. package/dist/src/link/base.js +4 -7
  53. package/dist/src/link/file.js +6 -6
  54. package/dist/src/link/galleryImage.js +1 -0
  55. package/dist/src/link/redirectTarget.d.ts +0 -2
  56. package/dist/src/link/redirectTarget.js +1 -1
  57. package/dist/src/magicLink.js +6 -8
  58. package/dist/src/nested.js +2 -2
  59. package/dist/src/nowiki/base.d.ts +2 -2
  60. package/dist/src/nowiki/base.js +3 -4
  61. package/dist/src/nowiki/comment.d.ts +3 -4
  62. package/dist/src/nowiki/comment.js +78 -28
  63. package/dist/src/nowiki/doubleUnderscore.d.ts +3 -3
  64. package/dist/src/nowiki/doubleUnderscore.js +68 -19
  65. package/dist/src/nowiki/index.js +1 -1
  66. package/dist/src/nowiki/noinclude.d.ts +1 -1
  67. package/dist/src/nowiki/noinclude.js +53 -3
  68. package/dist/src/nowiki/quote.js +18 -24
  69. package/dist/src/paramTag/index.d.ts +0 -2
  70. package/dist/src/paramTag/index.js +3 -3
  71. package/dist/src/parameter.js +3 -1
  72. package/dist/src/redirect.d.ts +4 -1
  73. package/dist/src/redirect.js +83 -33
  74. package/dist/src/syntax.d.ts +2 -2
  75. package/dist/src/syntax.js +3 -4
  76. package/dist/src/table/base.d.ts +4 -2
  77. package/dist/src/table/base.js +3 -2
  78. package/dist/src/table/index.d.ts +2 -3
  79. package/dist/src/table/index.js +11 -10
  80. package/dist/src/table/td.d.ts +0 -2
  81. package/dist/src/table/td.js +15 -6
  82. package/dist/src/table/tr.d.ts +2 -2
  83. package/dist/src/table/tr.js +2 -3
  84. package/dist/src/tagPair/ext.js +5 -7
  85. package/dist/src/tagPair/include.d.ts +6 -4
  86. package/dist/src/tagPair/include.js +76 -26
  87. package/dist/src/tagPair/index.d.ts +2 -4
  88. package/dist/src/tagPair/index.js +4 -5
  89. package/dist/src/transclude.d.ts +0 -2
  90. package/dist/src/transclude.js +9 -12
  91. package/dist/util/debug.js +15 -1
  92. package/dist/util/lint.js +3 -2
  93. package/dist/util/string.js +5 -5
  94. package/package.json +11 -11
package/dist/src/index.js CHANGED
@@ -43,6 +43,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
43
43
  exports.Token = void 0;
44
44
  const string_1 = require("../util/string");
45
45
  const constants_1 = require("../util/constants");
46
+ const debug_1 = require("../util/debug");
46
47
  const lint_1 = require("../util/lint");
47
48
  const index_1 = require("../index");
48
49
  const element_1 = require("../lib/element");
@@ -137,7 +138,7 @@ class Token extends element_1.AstElement {
137
138
  else if (isNaN(s.slice(-1))) {
138
139
  return this.#accum[Number(s.slice(0, -1))];
139
140
  }
140
- throw new Error(`解析错误!未正确标记的 Token:${s}`);
141
+ throw new Error(`Failed to build! Unrecognized token: ${s}`);
141
142
  });
142
143
  if (type === constants_1.BuildMethod.String) {
143
144
  return nodes.map(String).join('');
@@ -147,8 +148,8 @@ class Token extends element_1.AstElement {
147
148
  }
148
149
  return nodes;
149
150
  }
150
- /** 将占位符替换为子Token */
151
- #build() {
151
+ /** @private */
152
+ build() {
152
153
  this.#stage = constants_1.MAX_STAGE;
153
154
  const { length, firstChild } = this, str = String(firstChild);
154
155
  if (length === 1 && firstChild.type === 'text' && str.includes('\0')) {
@@ -156,7 +157,7 @@ class Token extends element_1.AstElement {
156
157
  this.normalize();
157
158
  if (this.type === 'root') {
158
159
  for (const token of this.#accum) {
159
- token.#build();
160
+ token.build();
160
161
  }
161
162
  }
162
163
  }
@@ -177,7 +178,7 @@ class Token extends element_1.AstElement {
177
178
  this.parseOnce(this.#stage, include);
178
179
  }
179
180
  if (n) {
180
- this.#build();
181
+ this.build();
181
182
  this.afterBuild();
182
183
  }
183
184
  return this;
@@ -288,16 +289,13 @@ class Token extends element_1.AstElement {
288
289
  case 'plain':
289
290
  return (this.constructor === Token);
290
291
  case 'config':
291
- return structuredClone(this.#config);
292
- case 'include': {
293
- if (this.#include !== undefined) {
294
- return this.#include;
295
- }
296
- const root = this.getRootNode();
297
- return (root !== this && root.getAttribute('include'));
298
- }
292
+ return this.#config;
293
+ case 'include':
294
+ return (this.#include ?? Boolean(this.getRootNode().#include));
299
295
  case 'accum':
300
296
  return this.#accum;
297
+ case 'built':
298
+ return this.#built;
301
299
  default:
302
300
  return super.getAttribute(key);
303
301
  }
@@ -323,14 +321,7 @@ class Token extends element_1.AstElement {
323
321
  }
324
322
  return token;
325
323
  }
326
- /**
327
- * 规范化页面标题
328
- * @param title 标题(含或不含命名空间前缀)
329
- * @param defaultNs 命名空间
330
- * @param halfParsed 仅供内部使用
331
- * @param decode 是否需要解码
332
- * @param selfLink 是否允许selfLink
333
- */
324
+ /** @private */
334
325
  normalizeTitle(title, defaultNs = 0, halfParsed, decode, selfLink) {
335
326
  return index_1.default.normalizeTitle(title, defaultNs, this.#include, this.#config, halfParsed, decode, selfLink);
336
327
  }
@@ -403,13 +394,13 @@ class Token extends element_1.AstElement {
403
394
  }
404
395
  return errors;
405
396
  }
406
- /** @override */
397
+ /** @private */
407
398
  toString(separator) {
408
- const root = this.getRootNode();
399
+ const { rev } = debug_1.Shadow, root = this.getRootNode();
409
400
  if (root.type === 'root'
410
401
  && root.#built) {
411
- this.#string ??= super.toString(separator);
412
- return this.#string;
402
+ this.#string ??= [rev, super.toString(separator)];
403
+ return this.#string[1];
413
404
  }
414
405
  return super.toString(separator);
415
406
  }
@@ -20,6 +20,4 @@ export declare abstract class LinkBaseToken extends Token {
20
20
  * @param delimiter `|`
21
21
  */
22
22
  constructor(link: string, linkText?: string, config?: Parser.Config, accum?: Token[], delimiter?: string);
23
- /** @override */
24
- text(): string;
25
23
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LinkBaseToken = void 0;
4
4
  const lint_1 = require("../../util/lint");
5
+ const rect_1 = require("../../lib/rect");
5
6
  const constants_1 = require("../../util/constants");
6
7
  const index_1 = require("../../index");
7
8
  const index_2 = require("../index");
@@ -37,6 +38,7 @@ class LinkBaseToken extends index_2.Token {
37
38
  this.#delimiter = this.buildFromStr(this.#delimiter, constants_1.BuildMethod.String);
38
39
  }
39
40
  this.setAttribute('name', this.#title.title);
41
+ super.afterBuild();
40
42
  }
41
43
  /** @private */
42
44
  setAttribute(key, value) {
@@ -55,7 +57,7 @@ class LinkBaseToken extends index_2.Token {
55
57
  const str = super.toString(this.#delimiter);
56
58
  return this.#bracket ? `[[${str}]]` : str;
57
59
  }
58
- /** @override */
60
+ /** @private */
59
61
  text() {
60
62
  const str = super.text('|');
61
63
  return this.#bracket ? `[[${str}]]` : str;
@@ -73,20 +75,16 @@ class LinkBaseToken extends index_2.Token {
73
75
  }
74
76
  /** @private */
75
77
  lint(start = this.getAbsoluteIndex(), re) {
76
- const errors = super.lint(start, re), { childNodes: [target, linkText], type: linkType } = this, { encoded, fragment } = this.#title;
77
- let rect;
78
+ const errors = super.lint(start, re), { childNodes: [target, linkText], type: linkType } = this, { encoded, fragment } = this.#title, rect = new rect_1.BoundingRect(this, start);
78
79
  if (target.childNodes.some(({ type }) => type === 'template')) {
79
- rect = { start, ...this.getRootNode().posFromIndex(start) };
80
80
  errors.push((0, lint_1.generateForChild)(target, rect, 'unknown-page', 'template in an internal link target', 'warning'));
81
81
  }
82
82
  if (encoded) {
83
- rect ??= { start, ...this.getRootNode().posFromIndex(start) };
84
83
  errors.push((0, lint_1.generateForChild)(target, rect, 'url-encoding', 'unnecessary URL encoding in an internal link'));
85
84
  }
86
85
  if (linkType === 'link' || linkType === 'category') {
87
86
  const textNode = linkText?.childNodes.find((c) => c.type === 'text' && c.data.includes('|'));
88
87
  if (textNode) {
89
- rect ??= { start, ...this.getRootNode().posFromIndex(start) };
90
88
  const e = (0, lint_1.generateForChild)(linkText, rect, 'pipe-like', 'additional "|" in the link text', 'warning');
91
89
  e.suggestions = [
92
90
  {
@@ -102,7 +100,6 @@ class LinkBaseToken extends index_2.Token {
102
100
  }
103
101
  }
104
102
  if (linkType !== 'link' && linkType !== 'redirect-target' && fragment !== undefined) {
105
- rect ??= { start, ...this.getRootNode().posFromIndex(start) };
106
103
  const e = (0, lint_1.generateForChild)(target, rect, 'no-ignored', 'useless fragment'), textNode = target.childNodes.find((c) => c.type === 'text' && c.data.includes('#'));
107
104
  if (textNode) {
108
105
  e.fix = {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FileToken = void 0;
4
4
  const string_1 = require("../../util/string");
5
5
  const lint_1 = require("../../util/lint");
6
+ const rect_1 = require("../../lib/rect");
6
7
  const index_1 = require("../../index");
7
8
  const base_1 = require("./base");
8
9
  const imageParameter_1 = require("../imageParameter");
@@ -61,9 +62,9 @@ class FileToken extends base_1.LinkBaseToken {
61
62
  const errors = super.lint(start, re), args = this.getAllArgs().filter(({ childNodes }) => {
62
63
  const visibleNodes = childNodes.filter(node => node.text().trim());
63
64
  return visibleNodes.length !== 1 || visibleNodes[0].type !== 'arg';
64
- }), keys = [...new Set(args.map(({ name }) => name))].filter(key => key !== 'invalid'), frameKeys = keys.filter(key => frame.has(key)), horizAlignKeys = keys.filter(key => horizAlign.has(key)), vertAlignKeys = keys.filter(key => vertAlign.has(key));
65
+ }), keys = [...new Set(args.map(({ name }) => name))].filter(key => key !== 'invalid'), frameKeys = keys.filter(key => frame.has(key)), horizAlignKeys = keys.filter(key => horizAlign.has(key)), vertAlignKeys = keys.filter(key => vertAlign.has(key)), rect = new rect_1.BoundingRect(this, start);
65
66
  if (this.closest('ext-link-text') && this.getValue('link')?.trim() !== '') {
66
- errors.push((0, lint_1.generateForSelf)(this, { start }, 'nested-link', 'internal link in an external link'));
67
+ errors.push((0, lint_1.generateForSelf)(this, rect, 'nested-link', 'internal link in an external link'));
67
68
  }
68
69
  if (args.length === keys.length
69
70
  && frameKeys.length < 2
@@ -71,7 +72,6 @@ class FileToken extends base_1.LinkBaseToken {
71
72
  && vertAlignKeys.length < 2) {
72
73
  return errors;
73
74
  }
74
- const rect = { start, ...this.getRootNode().posFromIndex(start) };
75
75
  /**
76
76
  * 图片参数到语法错误的映射
77
77
  * @param msg 消息键
@@ -120,15 +120,15 @@ class FileToken extends base_1.LinkBaseToken {
120
120
  }
121
121
  /** 获取图片框架属性参数节点 */
122
122
  getFrameArgs() {
123
- return this.#getTypedArgs(frame, '框架');
123
+ return this.#getTypedArgs(frame, 'frame');
124
124
  }
125
125
  /** 获取图片水平对齐参数节点 */
126
126
  getHorizAlignArgs() {
127
- return this.#getTypedArgs(horizAlign, '水平对齐');
127
+ return this.#getTypedArgs(horizAlign, 'horizontal-align');
128
128
  }
129
129
  /** 获取图片垂直对齐参数节点 */
130
130
  getVertAlignArgs() {
131
- return this.#getTypedArgs(vertAlign, '垂直对齐');
131
+ return this.#getTypedArgs(vertAlign, 'vertical-align');
132
132
  }
133
133
  /**
134
134
  * 获取生效的指定图片参数
@@ -54,6 +54,7 @@ class GalleryImageToken extends file_1.FileToken {
54
54
  /** @private */
55
55
  afterBuild() {
56
56
  this.#setName(this.getTitle());
57
+ super.afterBuild();
57
58
  }
58
59
  }
59
60
  exports.GalleryImageToken = GalleryImageToken;
@@ -18,6 +18,4 @@ export declare abstract class RedirectTargetToken extends LinkBaseToken {
18
18
  * @param delimiter `|`
19
19
  */
20
20
  constructor(link: string, linkText?: string, config?: Parser.Config, accum?: Token[]);
21
- /** @override */
22
- text(): string;
23
21
  }
@@ -27,7 +27,7 @@ class RedirectTargetToken extends base_1.LinkBaseToken {
27
27
  getTitle() {
28
28
  return this.normalizeTitle(this.firstChild.toString(), 0, true, true);
29
29
  }
30
- /** @override */
30
+ /** @private */
31
31
  text() {
32
32
  return `[[${this.firstChild.toString()}]]`;
33
33
  }
@@ -2,10 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MagicLinkToken = void 0;
4
4
  const lint_1 = require("../util/lint");
5
+ const rect_1 = require("../lib/rect");
5
6
  const string_1 = require("../util/string");
6
7
  const index_1 = require("../index");
7
8
  const index_2 = require("./index");
8
- const space = '(?:[\\p{Zs}\\t]|&nbsp;|&#0*160;|&#[xX]0*[aA]0;)';
9
+ const space = String.raw `(?:[\p{Zs}\t]|&nbsp;|&#0*160;|&#[xX]0*[aA]0;)`, spaceRegex = new RegExp(`${space}+`, 'gu');
9
10
  /**
10
11
  * 自由外链
11
12
  * @classdesc `{childNodes: ...AstText|CommentToken|IncludeToken|NoincludeToken}`
@@ -19,7 +20,7 @@ class MagicLinkToken extends index_2.Token {
19
20
  return type === 'magic-word' && String(name) in map ? map[name] : child;
20
21
  }));
21
22
  if (this.type === 'magic-link') {
22
- link = link.replace(new RegExp(`${space}+`, 'gu'), ' ');
23
+ link = link.replace(spaceRegex, ' ');
23
24
  if (link.startsWith('ISBN')) {
24
25
  link = `ISBN ${link.slice(5).replace(/[- ]/gu, '').replace(/x$/u, 'X')}`;
25
26
  }
@@ -30,14 +31,13 @@ class MagicLinkToken extends index_2.Token {
30
31
  * @param url 网址
31
32
  * @param type 类型
32
33
  */
33
- constructor(url, type = 'free-ext-link', config = index_1.default.getConfig(), accum = []) {
34
+ constructor(url, type = 'free-ext-link', config = index_1.default.getConfig(), accum) {
34
35
  super(url, config, accum, {});
35
36
  this.type = type;
36
37
  }
37
38
  /** @private */
38
39
  lint(start = this.getAbsoluteIndex(), re) {
39
- const errors = super.lint(start, re);
40
- let rect;
40
+ const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start);
41
41
  if (this.type === 'magic-link') {
42
42
  const { link } = this;
43
43
  if (link.startsWith('ISBN')) {
@@ -46,19 +46,17 @@ class MagicLinkToken extends index_2.Token {
46
46
  if (digits.length === 10 && digits.reduce((sum, d, i) => sum + d * (10 - i), 0) % 11
47
47
  || digits.length === 13 && (digits[12] === 10
48
48
  || digits.reduce((sum, d, i) => sum + d * (i % 2 ? 3 : 1), 0) % 10)) {
49
- rect = { start, ...this.getRootNode().posFromIndex(start) };
50
49
  errors.push((0, lint_1.generateForSelf)(this, rect, 'invalid-isbn', 'invalid ISBN'));
51
50
  }
52
51
  }
53
52
  return errors;
54
53
  }
55
- const source = `[,;。:!?()]+${this.type === 'ext-link-url' ? '|\\|+' : ''}`, regex = new RegExp(source, 'u'), regexGlobal = new RegExp(source, 'gu');
54
+ const source = `[,;。:!?()]+${this.type === 'ext-link-url' ? String.raw `|\|+` : ''}`, regex = new RegExp(source, 'u'), regexGlobal = new RegExp(source, 'gu');
56
55
  for (const child of this.childNodes) {
57
56
  const { type, data } = child;
58
57
  if (type !== 'text' || !regex.test(data)) {
59
58
  continue;
60
59
  }
61
- rect ??= { start, ...this.getRootNode().posFromIndex(start) };
62
60
  const refError = (0, lint_1.generateForChild)(child, rect, 'unterminated-url', '', 'warning');
63
61
  regexGlobal.lastIndex = 0;
64
62
  for (let mt = regexGlobal.exec(data); mt; mt = regexGlobal.exec(data)) {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NestedToken = void 0;
4
4
  const lint_1 = require("../util/lint");
5
+ const rect_1 = require("../lib/rect");
5
6
  const index_1 = require("../index");
6
7
  const index_2 = require("./index");
7
8
  const ext_1 = require("./tagPair/ext");
@@ -39,7 +40,7 @@ class NestedToken extends index_2.Token {
39
40
  }
40
41
  /** @private */
41
42
  lint(start = this.getAbsoluteIndex(), re) {
42
- let rect;
43
+ const rect = new rect_1.BoundingRect(this, start);
43
44
  return [
44
45
  ...super.lint(start, re),
45
46
  ...this.childNodes.filter(child => {
@@ -49,7 +50,6 @@ class NestedToken extends index_2.Token {
49
50
  const str = child.toString().trim();
50
51
  return str && !/^<!--.*-->$/su.test(str);
51
52
  }).map(child => {
52
- rect ??= { start, ...this.getRootNode().posFromIndex(start) };
53
53
  const e = (0, lint_1.generateForChild)(child, rect, 'no-ignored', index_1.default.msg('invalid content in <$1>', this.name));
54
54
  e.suggestions = [
55
55
  {
@@ -1,5 +1,5 @@
1
- import Parser from '../../index';
2
1
  import { Token } from '../index';
2
+ import type { Config } from '../../base';
3
3
  import type { AstText } from '../../lib/text';
4
4
  declare type NowikiTypes = 'ext-inner' | 'comment' | 'dd' | 'double-underscore' | 'hr' | 'list' | 'noinclude' | 'quote';
5
5
  /**
@@ -14,6 +14,6 @@ export declare abstract class NowikiBaseToken extends Token {
14
14
  /** 纯文本部分 */
15
15
  get innerText(): string;
16
16
  /** @param wikitext default: `''` */
17
- constructor(wikitext?: string, config?: Parser.Config, accum?: Token[]);
17
+ constructor(wikitext?: string, config?: Config, accum?: Token[]);
18
18
  }
19
19
  export {};
@@ -1,19 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NowikiBaseToken = void 0;
4
- const index_1 = require("../../index");
5
- const index_2 = require("../index");
4
+ const index_1 = require("../index");
6
5
  /**
7
6
  * 纯文字Token,不会被解析
8
7
  * @classdesc `{childNodes: [AstText]}`
9
8
  */
10
- class NowikiBaseToken extends index_2.Token {
9
+ class NowikiBaseToken extends index_1.Token {
11
10
  /** 纯文本部分 */
12
11
  get innerText() {
13
12
  return this.firstChild.data;
14
13
  }
15
14
  /** @param wikitext default: `''` */
16
- constructor(wikitext = '', config = index_1.default.getConfig(), accum = []) {
15
+ constructor(wikitext = '', config, accum) {
17
16
  super(wikitext, config, accum);
18
17
  }
19
18
  }
@@ -1,11 +1,10 @@
1
- import Parser from '../../index';
2
1
  import { NowikiBaseToken } from './base';
3
- import type { LintError } from '../../base';
2
+ import type { LintError, Config } from '../../base';
4
3
  import type { Token } from '../index';
4
+ /** HTML注释,不可见 */
5
5
  export declare abstract class CommentToken extends NowikiBaseToken {
6
6
  readonly type = "comment";
7
7
  closed: boolean;
8
8
  /** @param closed 是否闭合 */
9
- constructor(wikitext: string, closed?: boolean, config?: Parser.Config, accum?: Token[]);
9
+ constructor(wikitext: string, closed?: boolean, config?: Config, accum?: Token[]);
10
10
  }
11
- export {};
@@ -1,4 +1,38 @@
1
1
  "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
2
36
  Object.defineProperty(exports, "__esModule", { value: true });
3
37
  exports.CommentToken = void 0;
4
38
  const lint_1 = require("../../util/lint");
@@ -6,33 +40,49 @@ const hidden_1 = require("../../mixin/hidden");
6
40
  const index_1 = require("../../index");
7
41
  const base_1 = require("./base");
8
42
  /** HTML注释,不可见 */
9
- class CommentToken extends (0, hidden_1.hiddenToken)(base_1.NowikiBaseToken) {
10
- type = 'comment';
11
- closed;
12
- /** @param closed 是否闭合 */
13
- constructor(wikitext, closed = true, config = index_1.default.getConfig(), accum = []) {
14
- super(wikitext, config, accum);
15
- this.closed = closed;
16
- }
17
- /** @private */
18
- getAttribute(key) {
19
- return key === 'padding' ? 4 : super.getAttribute(key);
20
- }
21
- /** @private */
22
- lint(start = this.getAbsoluteIndex()) {
23
- if (this.closed) {
24
- return [];
43
+ let CommentToken = (() => {
44
+ let _classDecorators = [(0, hidden_1.hiddenToken)()];
45
+ let _classDescriptor;
46
+ let _classExtraInitializers = [];
47
+ let _classThis;
48
+ let _classSuper = base_1.NowikiBaseToken;
49
+ var CommentToken = class extends _classSuper {
50
+ static { _classThis = this; }
51
+ static {
52
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
53
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
54
+ CommentToken = _classThis = _classDescriptor.value;
55
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
56
+ __runInitializers(_classThis, _classExtraInitializers);
25
57
  }
26
- const e = (0, lint_1.generateForSelf)(this, { start }, 'unclosed-comment', index_1.default.msg('unclosed $1', 'HTML comment'));
27
- e.fix = {
28
- range: [e.endIndex, e.endIndex],
29
- text: '-->',
30
- };
31
- return [e];
32
- }
33
- /** @private */
34
- toString() {
35
- return `<!--${this.innerText}${this.closed ? '-->' : ''}`;
36
- }
37
- }
58
+ type = 'comment';
59
+ closed;
60
+ /** @param closed 是否闭合 */
61
+ constructor(wikitext, closed = true, config, accum) {
62
+ super(wikitext, config, accum);
63
+ this.closed = closed;
64
+ }
65
+ /** @private */
66
+ getAttribute(key) {
67
+ return key === 'padding' ? 4 : super.getAttribute(key);
68
+ }
69
+ /** @private */
70
+ lint(start = this.getAbsoluteIndex()) {
71
+ if (this.closed) {
72
+ return [];
73
+ }
74
+ const e = (0, lint_1.generateForSelf)(this, { start }, 'unclosed-comment', index_1.default.msg('unclosed $1', 'HTML comment'));
75
+ e.fix = {
76
+ range: [e.endIndex, e.endIndex],
77
+ text: '-->',
78
+ };
79
+ return [e];
80
+ }
81
+ /** @private */
82
+ toString() {
83
+ return `<!--${this.innerText}${this.closed ? '-->' : ''}`;
84
+ }
85
+ };
86
+ return CommentToken = _classThis;
87
+ })();
38
88
  exports.CommentToken = CommentToken;
@@ -1,12 +1,12 @@
1
- import Parser from '../../index';
2
1
  import { NowikiBaseToken } from './base';
2
+ import type { Config } from '../../base';
3
3
  import type { Token } from '../index';
4
+ /** 状态开关 */
4
5
  export declare abstract class DoubleUnderscoreToken extends NowikiBaseToken {
5
6
  readonly type = "double-underscore";
6
7
  /**
7
8
  * @param word 状态开关名
8
9
  * @param sensitive 是否固定大小写
9
10
  */
10
- constructor(word: string, sensitive: boolean, config?: Parser.Config, accum?: Token[]);
11
+ constructor(word: string, sensitive: boolean, config?: Config, accum?: Token[]);
11
12
  }
12
- export {};
@@ -1,26 +1,75 @@
1
1
  "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
2
36
  Object.defineProperty(exports, "__esModule", { value: true });
3
37
  exports.DoubleUnderscoreToken = void 0;
4
38
  const hidden_1 = require("../../mixin/hidden");
5
- const index_1 = require("../../index");
6
39
  const base_1 = require("./base");
7
40
  /** 状态开关 */
8
- class DoubleUnderscoreToken extends (0, hidden_1.hiddenToken)(base_1.NowikiBaseToken) {
9
- type = 'double-underscore';
10
- /**
11
- * @param word 状态开关名
12
- * @param sensitive 是否固定大小写
13
- */
14
- constructor(word, sensitive, config = index_1.default.getConfig(), accum = []) {
15
- super(word, config, accum);
16
- }
17
- /** @private */
18
- getAttribute(key) {
19
- return key === 'padding' ? 2 : super.getAttribute(key);
20
- }
21
- /** @private */
22
- toString() {
23
- return `__${this.innerText}__`;
24
- }
25
- }
41
+ let DoubleUnderscoreToken = (() => {
42
+ let _classDecorators = [(0, hidden_1.hiddenToken)(true)];
43
+ let _classDescriptor;
44
+ let _classExtraInitializers = [];
45
+ let _classThis;
46
+ let _classSuper = base_1.NowikiBaseToken;
47
+ var DoubleUnderscoreToken = class extends _classSuper {
48
+ static { _classThis = this; }
49
+ static {
50
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
51
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
52
+ DoubleUnderscoreToken = _classThis = _classDescriptor.value;
53
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
54
+ __runInitializers(_classThis, _classExtraInitializers);
55
+ }
56
+ type = 'double-underscore';
57
+ /**
58
+ * @param word 状态开关名
59
+ * @param sensitive 是否固定大小写
60
+ */
61
+ constructor(word, sensitive, config, accum) {
62
+ super(word, config, accum);
63
+ }
64
+ /** @private */
65
+ getAttribute(key) {
66
+ return key === 'padding' ? 2 : super.getAttribute(key);
67
+ }
68
+ /** @private */
69
+ toString() {
70
+ return `__${this.innerText}__`;
71
+ }
72
+ };
73
+ return DoubleUnderscoreToken = _classThis;
74
+ })();
26
75
  exports.DoubleUnderscoreToken = DoubleUnderscoreToken;
@@ -18,7 +18,7 @@ class NowikiToken extends base_1.NowikiBaseToken {
18
18
  };
19
19
  return [e];
20
20
  }
21
- return super.lint(start, new RegExp(`<\\s*(?:\\/\\s*)${name === 'nowiki' ? '' : '?'}(${name})\\b`, 'giu'));
21
+ return super.lint(start, new RegExp(String.raw `<\s*(?:/\s*)${name === 'nowiki' ? '' : '?'}(${name})\b`, 'giu'));
22
22
  }
23
23
  }
24
24
  exports.NowikiToken = NowikiToken;
@@ -1,5 +1,5 @@
1
1
  import { NowikiBaseToken } from './base';
2
+ /** `<noinclude>`和`</noinclude>`,不可进行任何更改 */
2
3
  export declare abstract class NoincludeToken extends NowikiBaseToken {
3
4
  readonly type = "noinclude";
4
5
  }
5
- export {};