wikiparser-node 1.19.0 → 1.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +3 -0
  2. package/bundle/bundle-es7.min.js +25 -32
  3. package/bundle/bundle-lsp.min.js +24 -97
  4. package/bundle/bundle.min.js +26 -33
  5. package/config/default.json +49 -3
  6. package/config/minimum.json +5 -1
  7. package/data/ext/math.json +660 -0
  8. package/dist/addon/table.js +24 -5
  9. package/dist/addon/transclude.js +4 -4
  10. package/dist/base.d.mts +1 -1
  11. package/dist/base.d.ts +1 -1
  12. package/dist/bin/config.js +26 -8
  13. package/dist/index.js +10 -1
  14. package/dist/internal.d.ts +2 -0
  15. package/dist/lib/document.d.ts +6 -1
  16. package/dist/lib/document.js +21 -5
  17. package/dist/lib/element.js +15 -21
  18. package/dist/lib/lsp.js +88 -59
  19. package/dist/lib/node.d.ts +4 -4
  20. package/dist/lib/node.js +21 -24
  21. package/dist/lib/text.js +13 -14
  22. package/dist/lib/title.js +2 -1
  23. package/dist/mixin/attributesParent.js +1 -1
  24. package/dist/mixin/fixed.d.ts +1 -2
  25. package/dist/mixin/fixed.js +2 -3
  26. package/dist/mixin/gapped.d.ts +4 -0
  27. package/dist/mixin/gapped.js +24 -0
  28. package/dist/mixin/hidden.js +1 -1
  29. package/dist/mixin/multiLine.d.ts +4 -0
  30. package/dist/mixin/multiLine.js +33 -0
  31. package/dist/mixin/noEscape.js +1 -1
  32. package/dist/mixin/padded.d.ts +5 -0
  33. package/dist/mixin/padded.js +24 -0
  34. package/dist/mixin/singleLine.js +1 -1
  35. package/dist/mixin/sol.js +1 -1
  36. package/dist/mixin/syntax.js +3 -3
  37. package/dist/parser/braces.js +8 -12
  38. package/dist/parser/commentAndExt.js +18 -2
  39. package/dist/parser/magicLinks.js +2 -2
  40. package/dist/parser/quotes.js +0 -4
  41. package/dist/parser/selector.js +5 -2
  42. package/dist/src/arg.js +10 -13
  43. package/dist/src/atom.js +2 -7
  44. package/dist/src/attribute.js +6 -6
  45. package/dist/src/attributes.js +10 -14
  46. package/dist/src/commented.d.ts +26 -0
  47. package/dist/src/commented.js +52 -0
  48. package/dist/src/converter.js +3 -6
  49. package/dist/src/converterFlags.js +266 -223
  50. package/dist/src/converterRule.d.ts +2 -2
  51. package/dist/src/converterRule.js +2 -2
  52. package/dist/src/extLink.d.ts +2 -3
  53. package/dist/src/extLink.js +222 -175
  54. package/dist/src/gallery.d.ts +4 -5
  55. package/dist/src/gallery.js +179 -144
  56. package/dist/src/heading.js +11 -11
  57. package/dist/src/hidden.js +2 -7
  58. package/dist/src/imageParameter.d.ts +2 -2
  59. package/dist/src/imageParameter.js +6 -5
  60. package/dist/src/imagemap.d.ts +2 -2
  61. package/dist/src/imagemap.js +155 -123
  62. package/dist/src/imagemapLink.d.ts +2 -2
  63. package/dist/src/index.js +44 -20
  64. package/dist/src/link/base.d.ts +2 -3
  65. package/dist/src/link/base.js +13 -15
  66. package/dist/src/link/file.d.ts +2 -3
  67. package/dist/src/link/file.js +3 -3
  68. package/dist/src/link/galleryImage.d.ts +2 -3
  69. package/dist/src/link/galleryImage.js +7 -13
  70. package/dist/src/link/redirectTarget.js +1 -1
  71. package/dist/src/magicLink.js +7 -9
  72. package/dist/src/nested.d.ts +2 -2
  73. package/dist/src/nested.js +4 -7
  74. package/dist/src/nowiki/comment.d.ts +1 -1
  75. package/dist/src/nowiki/comment.js +2 -5
  76. package/dist/src/nowiki/doubleUnderscore.d.ts +1 -1
  77. package/dist/src/nowiki/doubleUnderscore.js +2 -5
  78. package/dist/src/nowiki/index.d.ts +2 -2
  79. package/dist/src/nowiki/index.js +2 -1
  80. package/dist/src/nowiki/quote.d.ts +3 -3
  81. package/dist/src/nowiki/quote.js +13 -12
  82. package/dist/src/onlyinclude.js +6 -13
  83. package/dist/src/paramTag/index.d.ts +2 -2
  84. package/dist/src/paramTag/index.js +102 -66
  85. package/dist/src/paramTag/inputbox.d.ts +1 -1
  86. package/dist/src/parameter.d.ts +4 -5
  87. package/dist/src/parameter.js +13 -13
  88. package/dist/src/pre.d.ts +4 -5
  89. package/dist/src/pre.js +8 -17
  90. package/dist/src/syntax.d.ts +1 -1
  91. package/dist/src/syntax.js +2 -7
  92. package/dist/src/table/base.d.ts +2 -2
  93. package/dist/src/table/base.js +8 -8
  94. package/dist/src/table/index.js +1 -1
  95. package/dist/src/table/td.d.ts +3 -3
  96. package/dist/src/table/td.js +9 -9
  97. package/dist/src/table/tr.d.ts +2 -2
  98. package/dist/src/tagPair/ext.js +35 -30
  99. package/dist/src/tagPair/index.d.ts +1 -1
  100. package/dist/src/tagPair/index.js +2 -5
  101. package/dist/src/tagPair/translate.d.ts +38 -0
  102. package/dist/src/tagPair/translate.js +129 -0
  103. package/dist/src/transclude.js +5 -6
  104. package/dist/util/html.js +16 -1
  105. package/dist/util/lint.js +17 -30
  106. package/dist/util/sharable.js +29 -1
  107. package/dist/util/sharable.mjs +31 -3
  108. package/dist/util/string.js +14 -1
  109. package/extensions/dist/base.js +1 -1
  110. package/extensions/dist/lsp.js +13 -2
  111. package/package.json +7 -6
  112. package/extensions/es7/base.js +0 -320
  113. package/extensions/es7/lint.js +0 -97
@@ -1,8 +1,7 @@
1
- import Parser from '../../index';
2
1
  import { Token } from '../index';
3
2
  import { FileToken } from './file';
4
3
  import type { Title } from '../../lib/title';
5
- import type { LintError } from '../../base';
4
+ import type { Config, LintError } from '../../base';
6
5
  import type { AtomToken, ImageParameterToken } from '../../internal';
7
6
  declare type GalleryTypes = 'gallery' | 'imagemap';
8
7
  /**
@@ -20,7 +19,7 @@ export declare abstract class GalleryImageToken extends FileToken {
20
19
  * @param link 图片文件名
21
20
  * @param text 图片参数
22
21
  */
23
- constructor(type: GalleryTypes, link: string, text?: string, config?: Parser.Config, accum?: Token[]);
22
+ constructor(type: GalleryTypes, link: string, text?: string, config?: Config, accum?: Token[]);
24
23
  /**
25
24
  * @override
26
25
  * @param child node to be inserted / 待插入的子节点
@@ -33,15 +33,12 @@ 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
- };
39
36
  Object.defineProperty(exports, "__esModule", { value: true });
40
37
  exports.GalleryImageToken = void 0;
41
38
  const lint_1 = require("../../util/lint");
42
39
  const constants_1 = require("../../util/constants");
43
- const index_1 = __importDefault(require("../../index"));
44
- const index_2 = require("../index");
40
+ const padded_1 = require("../../mixin/padded");
41
+ const index_1 = require("../index");
45
42
  const file_1 = require("./file");
46
43
  /* NOT FOR BROWSER */
47
44
  const debug_1 = require("../../util/debug");
@@ -53,7 +50,7 @@ const imageParameter_1 = require("../imageParameter");
53
50
  * 图库图片
54
51
  */
55
52
  let GalleryImageToken = (() => {
56
- let _classDecorators = [(0, singleLine_1.singleLine)()];
53
+ let _classDecorators = [(0, singleLine_1.singleLine)(), (0, padded_1.padded)('')];
57
54
  let _classDescriptor;
58
55
  let _classExtraInitializers = [];
59
56
  let _classThis;
@@ -88,11 +85,11 @@ let GalleryImageToken = (() => {
88
85
  * @param link 图片文件名
89
86
  * @param text 图片参数
90
87
  */
91
- constructor(type, link, text, config = index_1.default.getConfig(), accum = []) {
88
+ constructor(type, link, text, config, accum = []) {
92
89
  let token;
93
90
  if (text !== undefined) {
94
91
  const { length } = accum;
95
- token = new index_2.Token(text, config, accum);
92
+ token = new index_1.Token(text, config, accum);
96
93
  for (let n = 1; n < constants_1.MAX_STAGE; n++) {
97
94
  token.parseOnce();
98
95
  }
@@ -101,6 +98,7 @@ let GalleryImageToken = (() => {
101
98
  super(link, token?.toString(), config, accum);
102
99
  this.setAttribute('bracket', false);
103
100
  this.privateType = `${type}-image`;
101
+ /* PRINT ONLY */
104
102
  this.seal('privateType', true);
105
103
  }
106
104
  /** @private */
@@ -109,10 +107,6 @@ let GalleryImageToken = (() => {
109
107
  return this.normalizeTitle(this.firstChild.toString(), imagemap ? 0 : 6, { halfParsed: true, temporary, decode: !imagemap });
110
108
  }
111
109
  /** @private */
112
- getAttribute(key) {
113
- return key === 'padding' ? 0 : super.getAttribute(key);
114
- }
115
- /** @private */
116
110
  lint(start = this.getAbsoluteIndex(), re) {
117
111
  const errors = super.lint(start, re), { ns,
118
112
  /* NOT FOR BROWSER */
@@ -145,7 +139,7 @@ let GalleryImageToken = (() => {
145
139
  // @ts-expect-error abstract class
146
140
  const token = new GalleryImageToken(this.type.slice(0, -6), '', undefined, this.getAttribute('config'));
147
141
  token.firstChild.safeReplaceWith(link);
148
- token.append(...linkText);
142
+ token.safeAppend(linkText);
149
143
  return token;
150
144
  });
151
145
  }
@@ -47,7 +47,7 @@ class RedirectTargetToken extends base_1.LinkBaseToken {
47
47
  lint(start = this.getAbsoluteIndex()) {
48
48
  const errors = super.lint(start, false);
49
49
  if (this.length === 2) {
50
- const e = (0, lint_1.generateForChild)(this.lastChild, { start }, 'no-ignored', 'useless link text');
50
+ const e = (0, lint_1.generateForChild)(this.lastChild, { start }, 'no-ignored', 'useless link text', 'warning');
51
51
  e.startIndex--;
52
52
  e.startCol--;
53
53
  e.fix = { range: [e.startIndex, e.endIndex], text: '', desc: 'remove' };
@@ -47,6 +47,7 @@ const index_2 = require("./index");
47
47
  /* NOT FOR BROWSER */
48
48
  const debug_1 = require("../util/debug");
49
49
  const constants_1 = require("../util/constants");
50
+ const html_1 = require("../util/html");
50
51
  const syntax_1 = require("../mixin/syntax");
51
52
  const space = String.raw `(?:[${string_1.zs}\t]|&nbsp;|&#0*160;|&#[xX]0*[aA]0;)`;
52
53
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions, es-x/no-regexp-unicode-property-escapes
@@ -205,14 +206,11 @@ let MagicLinkToken = (() => {
205
206
  }
206
207
  /* NOT FOR BROWSER */
207
208
  cloneNode() {
208
- const cloned = this.cloneChildNodes();
209
- return debug_1.Shadow.run(() => {
210
- // @ts-expect-error abstract class
211
- const token = new MagicLinkToken(undefined, this.type, this.getAttribute('config'));
212
- token.append(...cloned);
213
- token.setAttribute('pattern', this.pattern);
214
- return token;
215
- });
209
+ const token = (0, html_1.cloneNode)(this,
210
+ // @ts-expect-error abstract class
211
+ () => new MagicLinkToken(undefined, this.type, this.getAttribute('config')));
212
+ token.setAttribute('pattern', this.pattern);
213
+ return token;
216
214
  }
217
215
  insertAt(token, i) {
218
216
  if (typeof token !== 'string') {
@@ -235,7 +233,7 @@ let MagicLinkToken = (() => {
235
233
  setTarget(url) {
236
234
  const { childNodes } = index_1.default
237
235
  .parse(url, this.getAttribute('include'), 2, this.getAttribute('config'));
238
- this.replaceChildren(...childNodes);
236
+ this.safeReplaceChildren(childNodes);
239
237
  }
240
238
  /**
241
239
  * Check if it is a parameter of a template or magic word
@@ -17,12 +17,12 @@ export declare abstract class NestedToken extends Token {
17
17
  abstract get firstChild(): Child | undefined;
18
18
  abstract get lastChild(): Child | undefined;
19
19
  abstract get nextSibling(): undefined;
20
- abstract get previousSibling(): AttributesToken;
20
+ abstract get previousSibling(): AttributesToken | undefined;
21
21
  abstract get parentNode(): ExtToken | undefined;
22
22
  abstract get children(): Child[];
23
23
  abstract get firstElementChild(): Child | undefined;
24
24
  abstract get lastElementChild(): Child | undefined;
25
- abstract get previousElementSibling(): AttributesToken;
25
+ abstract get previousElementSibling(): AttributesToken | undefined;
26
26
  abstract get nextElementSibling(): undefined;
27
27
  abstract get parentElement(): ExtToken | undefined;
28
28
  get type(): 'ext-inner';
@@ -15,6 +15,7 @@ const noinclude_1 = require("./nowiki/noinclude");
15
15
  /* NOT FOR BROWSER */
16
16
  const debug_1 = require("../util/debug");
17
17
  const constants_1 = require("../util/constants");
18
+ const html_1 = require("../util/html");
18
19
  const childTypes = new Set(['comment', 'include', 'arg', 'template', 'magic-word']), lintRegex = [false, true].map(article => {
19
20
  const noinclude = article ? 'includeonly' : 'noinclude';
20
21
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
@@ -101,13 +102,9 @@ class NestedToken extends index_2.Token {
101
102
  return super.insertAt(token, i);
102
103
  }
103
104
  cloneNode() {
104
- const cloned = this.cloneChildNodes(), config = this.getAttribute('config');
105
- return debug_1.Shadow.run(() => {
106
- // @ts-expect-error abstract class
107
- const token = new NestedToken(undefined, this.#regex, this.#tags, config);
108
- token.append(...cloned);
109
- return token;
110
- });
105
+ return (0, html_1.cloneNode)(this,
106
+ // @ts-expect-error abstract class
107
+ () => new NestedToken(undefined, this.#regex, this.#tags, this.getAttribute('config')));
111
108
  }
112
109
  }
113
110
  exports.NestedToken = NestedToken;
@@ -1,6 +1,6 @@
1
1
  import { NowikiBaseToken } from './base';
2
2
  import type { LintError, Config } from '../../base';
3
- import type { Token } from '../index';
3
+ import type { Token } from '../../internal';
4
4
  /**
5
5
  * invisible HTML comment
6
6
  *
@@ -40,6 +40,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
40
40
  exports.CommentToken = void 0;
41
41
  const lint_1 = require("../../util/lint");
42
42
  const hidden_1 = require("../../mixin/hidden");
43
+ const padded_1 = require("../../mixin/padded");
43
44
  const index_1 = __importDefault(require("../../index"));
44
45
  const base_1 = require("./base");
45
46
  /* NOT FOR BROWSER */
@@ -52,7 +53,7 @@ const constants_1 = require("../../util/constants");
52
53
  * HTML注释,不可见
53
54
  */
54
55
  let CommentToken = (() => {
55
- let _classDecorators = [(0, hidden_1.hiddenToken)(false)];
56
+ let _classDecorators = [(0, hidden_1.hiddenToken)(false), (0, padded_1.padded)('<!--')];
56
57
  let _classDescriptor;
57
58
  let _classExtraInitializers = [];
58
59
  let _classThis;
@@ -85,10 +86,6 @@ let CommentToken = (() => {
85
86
  this.closed = closed;
86
87
  }
87
88
  /** @private */
88
- getAttribute(key) {
89
- return key === 'padding' ? 4 : super.getAttribute(key);
90
- }
91
- /** @private */
92
89
  lint(start = this.getAbsoluteIndex()) {
93
90
  if (this.closed) {
94
91
  return [];
@@ -1,6 +1,6 @@
1
1
  import { NowikiBaseToken } from './base';
2
2
  import type { Config } from '../../base';
3
- import type { Token } from '../index';
3
+ import type { Token } from '../../internal';
4
4
  /**
5
5
  * behavior switch
6
6
  *
@@ -36,6 +36,7 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.DoubleUnderscoreToken = void 0;
38
38
  const hidden_1 = require("../../mixin/hidden");
39
+ const padded_1 = require("../../mixin/padded");
39
40
  const base_1 = require("./base");
40
41
  /* NOT FOR BROWSER */
41
42
  const debug_1 = require("../../util/debug");
@@ -48,7 +49,7 @@ const syntax_1 = require("../../mixin/syntax");
48
49
  * 状态开关
49
50
  */
50
51
  let DoubleUnderscoreToken = (() => {
51
- let _classDecorators = [(0, syntax_1.syntax)(), (0, hidden_1.hiddenToken)()];
52
+ let _classDecorators = [(0, syntax_1.syntax)(), (0, hidden_1.hiddenToken)(), (0, padded_1.padded)('__')];
52
53
  let _classDescriptor;
53
54
  let _classExtraInitializers = [];
54
55
  let _classThis;
@@ -81,10 +82,6 @@ let DoubleUnderscoreToken = (() => {
81
82
  this.setAttribute('pattern', new RegExp(`^${word}$`, sensitive ? 'u' : 'iu'));
82
83
  }
83
84
  /** @private */
84
- getAttribute(key) {
85
- return key === 'padding' ? 2 : super.getAttribute(key);
86
- }
87
- /** @private */
88
85
  toString() {
89
86
  return `__${this.innerText}__`;
90
87
  }
@@ -9,10 +9,10 @@ import type { AttributesToken, ExtToken } from '../../internal';
9
9
  export declare abstract class NowikiToken extends NowikiBaseToken {
10
10
  readonly name: string;
11
11
  abstract get nextSibling(): undefined;
12
- abstract get previousSibling(): AttributesToken;
12
+ abstract get previousSibling(): AttributesToken | undefined;
13
13
  abstract get parentNode(): ExtToken | undefined;
14
14
  abstract get nextElementSibling(): undefined;
15
- abstract get previousElementSibling(): AttributesToken;
15
+ abstract get previousElementSibling(): AttributesToken | undefined;
16
16
  abstract get parentElement(): ExtToken | undefined;
17
17
  get type(): 'ext-inner';
18
18
  }
@@ -13,6 +13,7 @@ const constants_1 = require("../../util/constants");
13
13
  /* NOT FOR BROWSER END */
14
14
  /<\s*(?:\/\s*)?(nowiki)\b/giu; // eslint-disable-line @typescript-eslint/no-unused-expressions
15
15
  const getLintRegex = (0, common_1.getRegex)(name => new RegExp(String.raw `<\s*(?:/\s*)${name === 'nowiki' ? '' : '?'}(${name})\b`, 'giu'));
16
+ const voidExt = new Set(['templatestyles', 'section', 'languages']);
16
17
  /**
17
18
  * text-only token inside an extension tag
18
19
  *
@@ -26,7 +27,7 @@ class NowikiToken extends base_1.NowikiBaseToken {
26
27
  /** @private */
27
28
  lint(start = this.getAbsoluteIndex()) {
28
29
  const { name, firstChild: { data } } = this;
29
- if ((name === 'templatestyles' || name === 'section') && data) {
30
+ if (voidExt.has(name) && data) {
30
31
  const e = (0, lint_1.generateForSelf)(this, { start }, 'void-ext', index_1.default.msg('nothing should be in <$1>', name));
31
32
  e.fix = { range: [start, e.endIndex], text: '', desc: 'empty' };
32
33
  return [e];
@@ -1,7 +1,7 @@
1
1
  import { NowikiBaseToken } from './base';
2
- import type { LintError, AST, Config } from '../../base';
2
+ import type { LintError, Config, AST } from '../../base';
3
3
  import type { Font } from '../../lib/node';
4
- import type { Token } from '../index';
4
+ import type { Token } from '../../internal';
5
5
  /**
6
6
  * `''` and `'''`
7
7
  *
@@ -12,9 +12,9 @@ export declare abstract class QuoteToken extends NowikiBaseToken {
12
12
  get type(): 'quote';
13
13
  get bold(): boolean;
14
14
  get italic(): boolean;
15
- get font(): Font;
16
15
  /** whether to be closing quotes / 是否闭合 */
17
16
  get closing(): Partial<Font>;
17
+ get font(): Font;
18
18
  /** @param closing 是否闭合 */
19
19
  constructor(wikitext: string, closing: Font, config?: Config, accum?: Token[]);
20
20
  cloneNode(): this;
@@ -67,9 +67,7 @@ let QuoteToken = (() => {
67
67
  if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
68
68
  __runInitializers(_classThis, _classExtraInitializers);
69
69
  }
70
- /* NOT FOR BROWSER */
71
70
  #closing;
72
- /* NOT FOR BROWSER END */
73
71
  get type() {
74
72
  return 'quote';
75
73
  }
@@ -79,10 +77,6 @@ let QuoteToken = (() => {
79
77
  get italic() {
80
78
  return this.innerText.length !== 3;
81
79
  }
82
- /* NOT FOR BROWSER */
83
- get font() {
84
- return { bold: this.bold, italic: this.italic };
85
- }
86
80
  /** whether to be closing quotes / 是否闭合 */
87
81
  get closing() {
88
82
  return {
@@ -90,12 +84,16 @@ let QuoteToken = (() => {
90
84
  ...this.italic ? { italic: this.#closing.italic } : undefined,
91
85
  };
92
86
  }
87
+ /* NOT FOR BROWSER */
88
+ get font() {
89
+ return { bold: this.bold, italic: this.italic };
90
+ }
91
+ /* NOT FOR BROWSER END */
93
92
  /** @param closing 是否闭合 */
94
93
  constructor(wikitext, closing, config, accum) {
95
94
  super(wikitext, config, accum);
96
95
  this.#closing = closing;
97
96
  }
98
- /* NOT FOR BROWSER END */
99
97
  /** @private */
100
98
  text() {
101
99
  const { parentNode, innerText } = this;
@@ -103,7 +101,7 @@ let QuoteToken = (() => {
103
101
  }
104
102
  /** @private */
105
103
  lint(start = this.getAbsoluteIndex()) {
106
- const { previousSibling, nextSibling, bold } = this, message = index_1.default.msg('lonely "$1"', `'`), errors = [], rect = new rect_1.BoundingRect(this, start);
104
+ const { previousSibling, nextSibling, bold, closing } = this, previousData = previousSibling?.type === 'text' ? previousSibling.data : undefined, nextData = nextSibling?.type === 'text' ? nextSibling.data : undefined, message = index_1.default.msg('lonely "$1"', `'`), errors = [], rect = new rect_1.BoundingRect(this, start);
107
105
  /**
108
106
  * 获取建议
109
107
  * @param startIndex 起点
@@ -114,8 +112,11 @@ let QuoteToken = (() => {
114
112
  { desc: 'escape', range: [startIndex, endIndex], text: '&apos;'.repeat(length) },
115
113
  { desc: 'remove', range: [startIndex, endIndex], text: '' },
116
114
  ];
117
- if (previousSibling?.type === 'text' && previousSibling.data.endsWith(`'`)) {
118
- const e = (0, lint_1.generateForSelf)(this, rect, 'lonely-apos', message), { startIndex: endIndex, startLine: endLine, startCol: endCol } = e, [, { length }] = /(?:^|[^'])('+)$/u.exec(previousSibling.data), startIndex = start - length;
115
+ if (previousData?.endsWith(`'`)) {
116
+ const e = (0, lint_1.generateForSelf)(this, rect, 'lonely-apos', message, (closing.bold || closing.italic)
117
+ && (/[a-z\d]'$/iu.test(previousData) || nextData && /^[a-z\d]/iu.test(nextData))
118
+ ? 'warning'
119
+ : 'error'), { startIndex: endIndex, startLine: endLine, startCol: endCol } = e, [, { length }] = /(?:^|[^'])('+)$/u.exec(previousData), startIndex = start - length;
119
120
  errors.push({
120
121
  ...e,
121
122
  startIndex,
@@ -126,8 +127,8 @@ let QuoteToken = (() => {
126
127
  suggestions: getSuggestion(startIndex, endIndex, length),
127
128
  });
128
129
  }
129
- if (nextSibling?.type === 'text' && nextSibling.data.startsWith(`'`)) {
130
- const e = (0, lint_1.generateForSelf)(this, rect, 'lonely-apos', message), { endIndex: startIndex, endLine: startLine, endCol: startCol } = e, [{ length }] = /^'+/u.exec(nextSibling.data), endIndex = startIndex + length;
130
+ if (nextData?.startsWith(`'`)) {
131
+ const e = (0, lint_1.generateForSelf)(this, rect, 'lonely-apos', message), { endIndex: startIndex, endLine: startLine, endCol: startCol } = e, [{ length }] = /^'+/u.exec(nextData), endIndex = startIndex + length;
131
132
  errors.push({
132
133
  ...e,
133
134
  startIndex,
@@ -38,10 +38,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
38
  };
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
40
  exports.OnlyincludeToken = void 0;
41
+ const padded_1 = require("../mixin/padded");
41
42
  const index_1 = require("./index");
42
43
  /* NOT FOR BROWSER */
43
- const debug_1 = require("../util/debug");
44
44
  const constants_1 = require("../util/constants");
45
+ const html_1 = require("../util/html");
45
46
  const noEscape_1 = require("../mixin/noEscape");
46
47
  const index_2 = __importDefault(require("../index"));
47
48
  /* NOT FOR BROWSER END */
@@ -52,7 +53,7 @@ const index_2 = __importDefault(require("../index"));
52
53
  * @classdesc `{childNodes: (AstText|Token)[]}`
53
54
  */
54
55
  let OnlyincludeToken = (() => {
55
- let _classDecorators = [noEscape_1.noEscape];
56
+ let _classDecorators = [noEscape_1.noEscape, (0, padded_1.padded)('<onlyinclude>')];
56
57
  let _classDescriptor;
57
58
  let _classExtraInitializers = [];
58
59
  let _classThis;
@@ -88,11 +89,8 @@ let OnlyincludeToken = (() => {
88
89
  return `<onlyinclude>${super.toString(skip)}</onlyinclude>`;
89
90
  }
90
91
  /** @private */
91
- getAttribute(key) {
92
- if (key === 'padding') {
93
- return 13;
94
- }
95
- return (key === 'plain') || super.getAttribute(key);
92
+ isPlain() {
93
+ return true;
96
94
  }
97
95
  /** @private */
98
96
  print() {
@@ -103,12 +101,7 @@ let OnlyincludeToken = (() => {
103
101
  }
104
102
  /* NOT FOR BROWSER */
105
103
  cloneNode() {
106
- const cloned = this.cloneChildNodes();
107
- return debug_1.Shadow.run(() => {
108
- const token = new OnlyincludeToken(undefined, this.getAttribute('config'));
109
- token.append(...cloned);
110
- return token;
111
- });
104
+ return (0, html_1.cloneNode)(this, () => new OnlyincludeToken(undefined, this.getAttribute('config')));
112
105
  }
113
106
  };
114
107
  return OnlyincludeToken = _classThis;
@@ -13,13 +13,13 @@ export declare abstract class ParamTagToken extends Token {
13
13
  abstract get firstChild(): AtomToken | undefined;
14
14
  abstract get lastChild(): AtomToken | undefined;
15
15
  abstract get nextSibling(): undefined;
16
- abstract get previousSibling(): AttributesToken;
16
+ abstract get previousSibling(): AttributesToken | undefined;
17
17
  abstract get parentNode(): ExtToken | undefined;
18
18
  abstract get children(): AtomToken[];
19
19
  abstract get firstElementChild(): AtomToken | undefined;
20
20
  abstract get lastElementChild(): AtomToken | undefined;
21
21
  abstract get nextElementSibling(): undefined;
22
- abstract get previousElementSibling(): AttributesToken;
22
+ abstract get previousElementSibling(): AttributesToken | undefined;
23
23
  abstract get parentElement(): ExtToken | undefined;
24
24
  get type(): 'ext-inner';
25
25
  /** @class */
@@ -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
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
38
  };
@@ -7,89 +41,91 @@ exports.ParamTagToken = void 0;
7
41
  const lint_1 = require("../../util/lint");
8
42
  const rect_1 = require("../../lib/rect");
9
43
  const commentAndExt_1 = require("../../parser/commentAndExt");
44
+ const multiLine_1 = require("../../mixin/multiLine");
10
45
  const index_1 = __importDefault(require("../../index"));
11
46
  const index_2 = require("../index");
12
47
  const atom_1 = require("../atom");
13
48
  /* NOT FOR BROWSER */
14
- const debug_1 = require("../../util/debug");
15
49
  const constants_1 = require("../../util/constants");
50
+ const html_1 = require("../../util/html");
16
51
  const singleLine_1 = require("../../mixin/singleLine");
17
52
  /* NOT FOR BROWSER END */
18
53
  /**
19
54
  * `<dynamicpagelist>`
20
55
  * @classdesc `{childNodes: AtomToken[]}`
21
56
  */
22
- class ParamTagToken extends index_2.Token {
23
- /* NOT FOR BROWSER END */
24
- get type() {
25
- return 'ext-inner';
26
- }
27
- /** @class */
28
- constructor(include, wikitext, config = index_1.default.getConfig(), accum = [], acceptable) {
29
- super(undefined, config, accum, {
30
- AtomToken: ':',
31
- });
32
- if (wikitext) {
33
- const SingleLineAtomToken = (0, singleLine_1.singleLine)(!acceptable)(atom_1.AtomToken);
34
- this.append(...wikitext.split('\n')
35
- .map(line => acceptable ? line : (0, commentAndExt_1.parseCommentAndExt)(line, config, accum, include))
36
- .map(line => new SingleLineAtomToken(line, 'param-line', config, accum, {
37
- 'Stage-1': ':', ...acceptable,
38
- })));
57
+ let ParamTagToken = (() => {
58
+ let _classDecorators = [multiLine_1.multiLine];
59
+ let _classDescriptor;
60
+ let _classExtraInitializers = [];
61
+ let _classThis;
62
+ let _classSuper = index_2.Token;
63
+ var ParamTagToken = class extends _classSuper {
64
+ static { _classThis = this; }
65
+ static {
66
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
67
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
68
+ ParamTagToken = _classThis = _classDescriptor.value;
69
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
70
+ __runInitializers(_classThis, _classExtraInitializers);
39
71
  }
40
- accum.splice(accum.indexOf(this), 1);
41
- accum.push(this);
42
- }
43
- /** @private */
44
- toString(skip) {
45
- return super.toString(skip, '\n');
46
- }
47
- /** @private */
48
- text() {
49
- return super.text('\n');
50
- }
51
- /** @private */
52
- getGaps() {
53
- return 1;
54
- }
55
- /** @private */
56
- lint(start = this.getAbsoluteIndex()) {
57
- const rect = new rect_1.BoundingRect(this, start), msg = index_1.default.msg('invalid parameter of <$1>', this.name), errors = [];
58
- for (const child of this.childNodes) {
59
- child.setAttribute('aIndex', start);
60
- const grandChildren = child.childNodes
61
- .filter(({ type }) => type !== 'comment' && type !== 'include' && type !== 'noinclude');
62
- if (grandChildren.some(({ type }) => type === 'ext')) {
63
- errors.push((0, lint_1.generateForChild)(child, rect, 'no-ignored', msg));
72
+ /* NOT FOR BROWSER END */
73
+ get type() {
74
+ return 'ext-inner';
75
+ }
76
+ /** @class */
77
+ constructor(include, wikitext, config = index_1.default.getConfig(), accum = [], acceptable) {
78
+ super(undefined, config, accum, {
79
+ AtomToken: ':',
80
+ });
81
+ if (wikitext) {
82
+ const SingleLineAtomToken = (0, singleLine_1.singleLine)(!acceptable)(atom_1.AtomToken);
83
+ this.append(...wikitext.split('\n')
84
+ .map(line => acceptable ? line : (0, commentAndExt_1.parseCommentAndExt)(line, config, accum, include))
85
+ .map(line => new SingleLineAtomToken(line, 'param-line', config, accum, {
86
+ 'Stage-1': ':', ...acceptable,
87
+ })));
64
88
  }
65
- else {
66
- const i = grandChildren.findIndex(({ type }) => type !== 'text'), str = grandChildren.slice(0, i === -1 ? undefined : i).map(String).join('');
67
- if (str && !(i === -1 ? /^[a-z]+(?:\[\])?\s*=/iu : /^[a-z]+(?:\[\])?\s*(?:=|$)/iu).test(str)) {
68
- const e = (0, lint_1.generateForChild)(child, rect, 'no-ignored', msg);
69
- e.suggestions = [{ desc: 'remove', range: [e.startIndex, e.endIndex], text: '' }];
70
- errors.push(e);
89
+ accum.splice(accum.indexOf(this), 1);
90
+ accum.push(this);
91
+ }
92
+ /** @private */
93
+ lint(start = this.getAbsoluteIndex()) {
94
+ const rect = new rect_1.BoundingRect(this, start), msg = index_1.default.msg('invalid parameter of <$1>', this.name), errors = [];
95
+ for (const child of this.childNodes) {
96
+ child.setAttribute('aIndex', start);
97
+ const grandChildren = child.childNodes
98
+ .filter(({ type }) => type !== 'comment' && type !== 'include' && type !== 'noinclude');
99
+ if (grandChildren.some(({ type }) => type === 'ext')) {
100
+ errors.push((0, lint_1.generateForChild)(child, rect, 'no-ignored', msg));
71
101
  }
72
102
  else {
73
- errors.push(...child.lint(start, false));
103
+ const i = grandChildren.findIndex(({ type }) => type !== 'text'), str = grandChildren.slice(0, i === -1 ? undefined : i).map(String).join('');
104
+ if (str && !(i === -1 ? /^[a-z]+(?:\[\])?\s*=/iu : /^[a-z]+(?:\[\])?\s*(?:=|$)/iu).test(str)) {
105
+ const e = (0, lint_1.generateForChild)(child, rect, 'no-ignored', msg);
106
+ e.suggestions = [{ desc: 'remove', range: [e.startIndex, e.endIndex], text: '' }];
107
+ errors.push(e);
108
+ }
109
+ else {
110
+ const childErrors = child.lint(start, false);
111
+ if (childErrors.length > 0) {
112
+ errors.push(...childErrors);
113
+ }
114
+ }
74
115
  }
116
+ start += child.toString().length + 1;
75
117
  }
76
- start += child.toString().length + 1;
118
+ return errors;
77
119
  }
78
- return errors;
79
- }
80
- /** @private */
81
- print() {
82
- return super.print({ sep: '\n' });
83
- }
84
- /* NOT FOR BROWSER */
85
- cloneNode() {
86
- const cloned = this.cloneChildNodes();
87
- return debug_1.Shadow.run(() => {
88
- const C = this.constructor, token = new C(this.getAttribute('include'), undefined, this.getAttribute('config'));
89
- token.append(...cloned);
90
- return token;
91
- });
92
- }
93
- }
120
+ /* NOT FOR BROWSER */
121
+ cloneNode() {
122
+ return (0, html_1.cloneNode)(this, () => {
123
+ const C = this.constructor;
124
+ return new C(this.getAttribute('include'), undefined, this.getAttribute('config'));
125
+ });
126
+ }
127
+ };
128
+ return ParamTagToken = _classThis;
129
+ })();
94
130
  exports.ParamTagToken = ParamTagToken;
95
131
  constants_1.classes['ParamTagToken'] = __filename;