wikiparser-node 1.16.6 → 1.17.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 (98) hide show
  1. package/README.md +1 -0
  2. package/bundle/bundle.es7.js +26 -26
  3. package/bundle/bundle.lsp.js +27 -27
  4. package/bundle/bundle.min.js +26 -26
  5. package/config/.schema.json +6 -2
  6. package/data/.schema.json +7 -0
  7. package/data/ext/mapframe.json +4 -0
  8. package/data/ext/maplink.json +4 -0
  9. package/data/ext/templatedata.json +184 -0
  10. package/dist/addon/table.js +16 -10
  11. package/dist/addon/token.js +26 -32
  12. package/dist/addon/transclude.js +6 -3
  13. package/dist/base.d.mts +4 -2
  14. package/dist/base.d.ts +4 -2
  15. package/dist/base.js +2 -0
  16. package/dist/base.mjs +3 -1
  17. package/dist/index.d.ts +2 -2
  18. package/dist/index.js +33 -21
  19. package/dist/lib/document.d.ts +53 -0
  20. package/dist/lib/document.js +121 -0
  21. package/dist/lib/element.js +6 -3
  22. package/dist/lib/lsp.d.ts +5 -7
  23. package/dist/lib/lsp.js +154 -28
  24. package/dist/lib/node.js +19 -9
  25. package/dist/lib/text.js +4 -1
  26. package/dist/lib/title.js +9 -6
  27. package/dist/mixin/attributesParent.d.ts +8 -0
  28. package/dist/mixin/attributesParent.js +4 -0
  29. package/dist/parser/links.js +4 -1
  30. package/dist/parser/redirect.js +4 -1
  31. package/dist/src/arg.d.ts +2 -3
  32. package/dist/src/arg.js +16 -9
  33. package/dist/src/attribute.d.ts +12 -1
  34. package/dist/src/attribute.js +69 -1
  35. package/dist/src/attributes.d.ts +10 -3
  36. package/dist/src/attributes.js +15 -2
  37. package/dist/src/converter.d.ts +64 -5
  38. package/dist/src/converter.js +163 -131
  39. package/dist/src/converterFlags.d.ts +2 -3
  40. package/dist/src/converterFlags.js +5 -6
  41. package/dist/src/converterRule.js +4 -1
  42. package/dist/src/extLink.d.ts +19 -3
  43. package/dist/src/extLink.js +177 -194
  44. package/dist/src/gallery.js +7 -3
  45. package/dist/src/heading.d.ts +2 -3
  46. package/dist/src/heading.js +10 -5
  47. package/dist/src/html.d.ts +0 -3
  48. package/dist/src/html.js +90 -93
  49. package/dist/src/imageParameter.d.ts +2 -3
  50. package/dist/src/imageParameter.js +10 -4
  51. package/dist/src/imagemap.js +4 -1
  52. package/dist/src/imagemapLink.d.ts +2 -2
  53. package/dist/src/imagemapLink.js +5 -6
  54. package/dist/src/index.d.ts +6 -0
  55. package/dist/src/index.js +54 -4
  56. package/dist/src/link/base.js +8 -2
  57. package/dist/src/link/file.js +11 -2
  58. package/dist/src/link/galleryImage.d.ts +1 -0
  59. package/dist/src/link/galleryImage.js +15 -1
  60. package/dist/src/magicLink.js +4 -1
  61. package/dist/src/nested.d.ts +2 -3
  62. package/dist/src/nested.js +5 -2
  63. package/dist/src/nowiki/comment.js +4 -1
  64. package/dist/src/nowiki/doubleUnderscore.d.ts +2 -2
  65. package/dist/src/nowiki/doubleUnderscore.js +1 -2
  66. package/dist/src/nowiki/index.js +4 -1
  67. package/dist/src/nowiki/quote.js +4 -1
  68. package/dist/src/onlyinclude.js +4 -1
  69. package/dist/src/paramTag/index.js +5 -1
  70. package/dist/src/paramTag/inputbox.js +4 -1
  71. package/dist/src/parameter.js +4 -1
  72. package/dist/src/pre.js +4 -1
  73. package/dist/src/redirect.d.ts +2 -3
  74. package/dist/src/redirect.js +7 -6
  75. package/dist/src/table/base.js +4 -1
  76. package/dist/src/table/index.js +10 -3
  77. package/dist/src/table/td.d.ts +2 -2
  78. package/dist/src/table/td.js +5 -2
  79. package/dist/src/tagPair/ext.js +17 -5
  80. package/dist/src/tagPair/include.js +4 -1
  81. package/dist/src/tagPair/index.js +4 -1
  82. package/dist/src/transclude.d.ts +2 -3
  83. package/dist/src/transclude.js +20 -11
  84. package/dist/util/debug.js +1 -13
  85. package/dist/util/diff.js +20 -6
  86. package/dist/util/lint.js +4 -1
  87. package/dist/util/string.js +5 -2
  88. package/extensions/dist/base.js +29 -17
  89. package/extensions/dist/lint.js +1 -0
  90. package/extensions/dist/lsp.js +30 -22
  91. package/extensions/es7/base.js +29 -17
  92. package/extensions/es7/lint.js +1 -0
  93. package/extensions/typings.d.ts +9 -3
  94. package/package.json +12 -6
  95. package/dist/mixin/flagsParent.d.ts +0 -69
  96. package/dist/mixin/flagsParent.js +0 -64
  97. package/dist/mixin/magicLinkParent.d.ts +0 -25
  98. package/dist/mixin/magicLinkParent.js +0 -43
@@ -1,11 +1,14 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.NestedToken = void 0;
4
7
  const lint_1 = require("../util/lint");
5
8
  const rect_1 = require("../lib/rect");
6
9
  const commentAndExt_1 = require("../parser/commentAndExt");
7
10
  const braces_1 = require("../parser/braces");
8
- const index_1 = require("../index");
11
+ const index_1 = __importDefault(require("../index"));
9
12
  const index_2 = require("./index");
10
13
  const ext_1 = require("./tagPair/ext");
11
14
  const noinclude_1 = require("./nowiki/noinclude");
@@ -30,7 +33,7 @@ class NestedToken extends index_2.Token {
30
33
  * @param regex 内层正则
31
34
  * @param tags 内层标签名
32
35
  */
33
- constructor(wikitext, regex, tags, config = index_1.default.getConfig(), accum = []) {
36
+ constructor(wikitext, regex, tags, config, accum = []) {
34
37
  if (typeof regex === 'boolean') {
35
38
  const placeholder = Symbol('InputboxToken'), { length } = accum;
36
39
  accum.push(placeholder);
@@ -33,11 +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.CommentToken = void 0;
38
41
  const lint_1 = require("../../util/lint");
39
42
  const hidden_1 = require("../../mixin/hidden");
40
- const index_1 = require("../../index");
43
+ const index_1 = __importDefault(require("../../index"));
41
44
  const base_1 = require("./base");
42
45
  /* NOT FOR BROWSER */
43
46
  const debug_1 = require("../../util/debug");
@@ -1,5 +1,5 @@
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
5
  * behavior switch
@@ -14,6 +14,6 @@ export declare abstract class DoubleUnderscoreToken extends NowikiBaseToken {
14
14
  * @param word 状态开关名
15
15
  * @param sensitive 是否固定大小写
16
16
  */
17
- constructor(word: string, sensitive: boolean, config?: Parser.Config, accum?: Token[]);
17
+ constructor(word: string, sensitive: boolean, config: Config, accum?: Token[]);
18
18
  cloneNode(): this;
19
19
  }
@@ -36,7 +36,6 @@ 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 index_1 = require("../../index");
40
39
  const base_1 = require("./base");
41
40
  /* NOT FOR BROWSER */
42
41
  const debug_1 = require("../../util/debug");
@@ -72,7 +71,7 @@ let DoubleUnderscoreToken = (() => {
72
71
  * @param word 状态开关名
73
72
  * @param sensitive 是否固定大小写
74
73
  */
75
- constructor(word, sensitive, config = index_1.default.getConfig(), accum) {
74
+ constructor(word, sensitive, config, accum) {
76
75
  super(word, config, accum);
77
76
  /* NOT FOR BROWSER */
78
77
  const lc = word.toLowerCase();
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.NowikiToken = void 0;
4
7
  const lint_1 = require("../../util/lint");
5
- const index_1 = require("../../index");
8
+ const index_1 = __importDefault(require("../../index"));
6
9
  const base_1 = require("./base");
7
10
  /* NOT FOR BROWSER */
8
11
  const constants_1 = require("../../util/constants");
@@ -33,11 +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.QuoteToken = void 0;
38
41
  const lint_1 = require("../../util/lint");
39
42
  const rect_1 = require("../../lib/rect");
40
- const index_1 = require("../../index");
43
+ const index_1 = __importDefault(require("../../index"));
41
44
  const base_1 = require("./base");
42
45
  /* NOT FOR BROWSER */
43
46
  const constants_1 = require("../../util/constants");
@@ -1,11 +1,14 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.OnlyincludeToken = void 0;
4
7
  const index_1 = require("./index");
5
8
  /* NOT FOR BROWSER */
6
9
  const debug_1 = require("../util/debug");
7
10
  const constants_1 = require("../util/constants");
8
- const index_2 = require("../index");
11
+ const index_2 = __importDefault(require("../index"));
9
12
  /* NOT FOR BROWSER END */
10
13
  /**
11
14
  * `<onlyinclude>` during transclusion
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.ParamTagToken = void 0;
4
7
  const lint_1 = require("../../util/lint");
5
8
  const rect_1 = require("../../lib/rect");
6
9
  const commentAndExt_1 = require("../../parser/commentAndExt");
7
- const index_1 = require("../../index");
10
+ const index_1 = __importDefault(require("../../index"));
8
11
  const index_2 = require("../index");
9
12
  const atom_1 = require("../atom");
10
13
  /* NOT FOR BROWSER */
@@ -53,6 +56,7 @@ class ParamTagToken extends index_2.Token {
53
56
  lint(start = this.getAbsoluteIndex()) {
54
57
  const rect = new rect_1.BoundingRect(this, start), msg = index_1.default.msg('invalid parameter of <$1>', this.name), errors = [];
55
58
  for (const child of this.childNodes) {
59
+ child.setAttribute('aIndex', start);
56
60
  const grandChildren = child.childNodes
57
61
  .filter(({ type }) => type !== 'comment' && type !== 'include' && type !== 'noinclude');
58
62
  if (grandChildren.some(({ type }) => type === 'ext')) {
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.InputboxToken = void 0;
4
7
  const commentAndExt_1 = require("../../parser/commentAndExt");
5
8
  const braces_1 = require("../../parser/braces");
6
- const index_1 = require("../../index");
9
+ const index_1 = __importDefault(require("../../index"));
7
10
  const index_2 = require("./index");
8
11
  /* NOT FOR BROWSER */
9
12
  const constants_1 = require("../../util/constants");
@@ -33,11 +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.ParameterToken = void 0;
38
41
  const string_1 = require("../util/string");
39
42
  const lint_1 = require("../util/lint");
40
- const index_1 = require("../index");
43
+ const index_1 = __importDefault(require("../index"));
41
44
  const index_2 = require("./index");
42
45
  /* NOT FOR BROWSER */
43
46
  const debug_1 = require("../util/debug");
package/dist/src/pre.js CHANGED
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.PreToken = void 0;
4
7
  const constants_1 = require("../util/constants");
5
- const index_1 = require("../index");
8
+ const index_1 = __importDefault(require("../index"));
6
9
  const index_2 = require("./index");
7
10
  const noinclude_1 = require("./nowiki/noinclude");
8
11
  /* NOT FOR BROWSER */
@@ -1,8 +1,7 @@
1
- import Parser from '../index';
2
1
  import { Token } from './index';
3
2
  import { SyntaxToken } from './syntax';
4
3
  import { RedirectTargetToken } from './link/redirectTarget';
5
- import type { LintError } from '../base';
4
+ import type { Config, LintError } from '../base';
6
5
  /**
7
6
  * redirect
8
7
  *
@@ -27,6 +26,6 @@ export declare abstract class RedirectToken extends Token {
27
26
  * @param text 重定向显示文本(无效)
28
27
  * @param post trailing whitespace
29
28
  */
30
- constructor(pre: string, syntax: string | undefined, link: string, text: string | undefined, post: string, config?: Parser.Config, accum?: Token[]);
29
+ constructor(pre: string, syntax: string | undefined, link: string, text: string | undefined, post: string, config: Config, accum?: Token[]);
31
30
  cloneNode(): this;
32
31
  }
@@ -36,8 +36,7 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.RedirectToken = void 0;
38
38
  const hidden_1 = require("../mixin/hidden");
39
- const index_1 = require("../index");
40
- const index_2 = require("./index");
39
+ const index_1 = require("./index");
41
40
  const syntax_1 = require("./syntax");
42
41
  const redirectTarget_1 = require("./link/redirectTarget");
43
42
  /* NOT FOR BROWSER */
@@ -56,7 +55,7 @@ let RedirectToken = (() => {
56
55
  let _classDescriptor;
57
56
  let _classExtraInitializers = [];
58
57
  let _classThis;
59
- let _classSuper = index_2.Token;
58
+ let _classSuper = index_1.Token;
60
59
  var RedirectToken = class extends _classSuper {
61
60
  static { _classThis = this; }
62
61
  static {
@@ -79,7 +78,7 @@ let RedirectToken = (() => {
79
78
  * @param text 重定向显示文本(无效)
80
79
  * @param post trailing whitespace
81
80
  */
82
- constructor(pre, syntax, link, text, post, config = index_1.default.getConfig(), accum = []) {
81
+ constructor(pre, syntax, link, text, post, config, accum = []) {
83
82
  super(undefined, config, accum);
84
83
  this.#pre = pre;
85
84
  this.#post = post;
@@ -101,7 +100,9 @@ let RedirectToken = (() => {
101
100
  }
102
101
  /** @private */
103
102
  lint(start = this.getAbsoluteIndex()) {
104
- return this.lastChild.lint(start + this.#pre.length + this.firstChild.toString().length);
103
+ const index = start + this.#pre.length + this.firstChild.toString().length;
104
+ this.lastChild.setAttribute('aIndex', index);
105
+ return this.lastChild.lint(index);
105
106
  }
106
107
  /** @private */
107
108
  print() {
@@ -112,7 +113,7 @@ let RedirectToken = (() => {
112
113
  const cloned = this.cloneChildNodes(), config = this.getAttribute('config');
113
114
  return debug_1.Shadow.run(() => {
114
115
  // @ts-expect-error abstract class
115
- const token = new RedirectToken([this.#pre, undefined, '', undefined, this.#post], config, []);
116
+ const token = new RedirectToken(this.#pre, undefined, '', undefined, this.#post, config, []);
116
117
  token.firstChild.safeReplaceWith(cloned[0]);
117
118
  token.lastChild.safeReplaceWith(cloned[1]);
118
119
  return token;
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.TableBaseToken = void 0;
4
7
  const attributesParent_1 = require("../../mixin/attributesParent");
5
- const index_1 = require("../../index");
8
+ const index_1 = __importDefault(require("../../index"));
6
9
  const index_2 = require("../index");
7
10
  const syntax_1 = require("../syntax");
8
11
  const attributes_1 = require("../attributes");
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.TableToken = exports.Layout = exports.isRowEnd = void 0;
4
7
  const lint_1 = require("../../util/lint");
5
8
  const debug_1 = require("../../util/debug");
6
9
  const rect_1 = require("../../lib/rect");
7
- const index_1 = require("../../index");
10
+ const index_1 = __importDefault(require("../../index"));
8
11
  const trBase_1 = require("./trBase");
9
12
  const syntax_1 = require("../syntax");
10
13
  /* NOT FOR BROWSER */
@@ -153,7 +156,8 @@ class TableToken extends trBase_1.TrBaseToken {
153
156
  */
154
157
  getLayout(stop) {
155
158
  const rows = this.getAllRows(), { length } = rows, layout = new Layout(...emptyArray(length, () => []));
156
- for (const [i, rowLayout] of layout.entries()) {
159
+ for (let i = 0; i < layout.length; i++) {
160
+ const rowLayout = layout[i];
157
161
  /* NOT FOR BROWSER */
158
162
  if (i > (stop?.row ?? stop?.y ?? NaN)) {
159
163
  break;
@@ -573,7 +577,10 @@ class TableToken extends trBase_1.TrBaseToken {
573
577
  * @param token 表格或表格行
574
578
  */
575
579
  const filter = (token) => token.childNodes.filter((0, debug_1.isToken)('table-inter'));
576
- const { childNodes } = this, tr = childNodes.filter((0, debug_1.isToken)('tr')), newOpt = { ...opt, nowrap: true };
580
+ const { childNodes } = this, tr = childNodes.filter((0, debug_1.isToken)('tr')), newOpt = {
581
+ ...opt,
582
+ nowrap: true,
583
+ };
577
584
  return `${[this, ...tr].flatMap(filter) // eslint-disable-line es-x/no-array-prototype-flat
578
585
  .map(token => token.toHtmlInternal(newOpt).trim())
579
586
  .join(' ')}<table${childNodes[1].toHtmlInternal()}>${opt?.nowrap ? ' ' : '\n'}<tbody>${super.toHtmlInternal(opt)}${(0, html_1.html)(tr, '', opt)}</tbody></table>`;
@@ -1,7 +1,7 @@
1
1
  import Parser from '../../index';
2
2
  import { Token } from '../index';
3
3
  import { TableBaseToken } from './base';
4
- import type { LintError, AST } from '../../base';
4
+ import type { LintError, AST, Config } from '../../base';
5
5
  import type { SyntaxToken, AttributesToken, TrToken, TableToken } from '../../internal';
6
6
  export type TdSubtypes = 'td' | 'th' | 'caption';
7
7
  export interface TdSpanAttrs {
@@ -76,5 +76,5 @@ export declare abstract class TdToken extends TableBaseToken {
76
76
  * @param include 是否嵌入
77
77
  * @param config
78
78
  */
79
- export declare const createTd: (inner: string | Token, subtype?: TdSubtypes, attr?: TdAttrs, include?: boolean, config?: Parser.Config) => TdToken;
79
+ export declare const createTd: (inner: string | Token, subtype?: TdSubtypes, attr?: TdAttrs, include?: boolean, config?: Config) => TdToken;
80
80
  export {};
@@ -33,12 +33,15 @@ 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.createTd = exports.TdToken = void 0;
38
41
  const lint_1 = require("../../util/lint");
39
42
  const constants_1 = require("../../util/constants");
40
43
  const rect_1 = require("../../lib/rect");
41
- const index_1 = require("../../index");
44
+ const index_1 = __importDefault(require("../../index"));
42
45
  const index_2 = require("../index");
43
46
  const base_1 = require("./base");
44
47
  /* NOT FOR BROWSER */
@@ -364,7 +367,7 @@ exports.TdToken = TdToken;
364
367
  * @param include 是否嵌入
365
368
  * @param config
366
369
  */
367
- const createTd = (inner, subtype = 'td', attr = {}, include, config = index_1.default.getConfig()) => {
370
+ const createTd = (inner, subtype = 'td', attr = {}, include, config) => {
368
371
  const innerToken = typeof inner === 'string' ? index_1.default.parse(inner, include, undefined, config) : inner,
369
372
  // @ts-expect-error abstract class
370
373
  token = debug_1.Shadow.run(() => new TdToken('\n|', undefined, config));
@@ -33,11 +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.ExtToken = void 0;
38
41
  const lint_1 = require("../../util/lint");
39
42
  const rect_1 = require("../../lib/rect");
40
- const index_1 = require("../../index");
43
+ const index_1 = __importDefault(require("../../index"));
41
44
  const attributesParent_1 = require("../../mixin/attributesParent");
42
45
  const index_2 = require("../index");
43
46
  const index_3 = require("./index");
@@ -97,7 +100,11 @@ let ExtToken = (() => {
97
100
  constructor(name, attr, inner, closed, config = index_1.default.getConfig(), include = false, accum = []) {
98
101
  const lcName = name.toLowerCase(),
99
102
  // @ts-expect-error abstract class
100
- attrToken = new attributes_1.AttributesToken(!attr || /^\s/u.test(attr) ? attr : ` ${attr}`, 'ext-attrs', lcName, config, accum), newConfig = { ...config, ext: del(config.ext, lcName), excludes: [...config.excludes ?? []] };
103
+ attrToken = new attributes_1.AttributesToken(!attr || /^\s/u.test(attr) ? attr : ` ${attr}`, 'ext-attrs', lcName, config, accum), newConfig = {
104
+ ...config,
105
+ ext: del(config.ext, lcName),
106
+ excludes: [...config.excludes ?? []],
107
+ };
101
108
  let innerToken;
102
109
  switch (lcName) {
103
110
  case 'tab':
@@ -203,11 +210,16 @@ let ExtToken = (() => {
203
210
  case 'nowiki':
204
211
  return (0, string_1.newline)(lastChild.toHtmlInternal());
205
212
  case 'pre':
206
- return `<pre${firstChild.toHtmlInternal()}>${(0, string_1.newline)(lastChild.toHtmlInternal({ ...opt, nowrap: false }))}</pre>`;
213
+ return `<pre${firstChild.toHtmlInternal()}>${(0, string_1.newline)(lastChild.toHtmlInternal({
214
+ ...opt,
215
+ nowrap: false,
216
+ }))}</pre>`;
207
217
  case 'poem':
208
218
  firstChild.classList.add('poem');
209
- return `<div${firstChild.toHtmlInternal()}>${lastChild.toHtmlInternal({ ...opt, nowrap: false })
210
- .replace(/(?<!^|<hr>)\n(?!$)/gu, '<br>\n')
219
+ return `<div${firstChild.toHtmlInternal()}>${lastChild.toHtmlInternal({
220
+ ...opt,
221
+ nowrap: false,
222
+ }).replace(/(?<!^|<hr>)\n(?!$)/gu, '<br>\n')
211
223
  .replace(/^ +/gmu, p => '&nbsp;'.repeat(p.length))}</div>`;
212
224
  case 'gallery': {
213
225
  const caption = firstChild.getAttrToken('caption'), perrow = parseInt(String(firstChild.getAttr('perrow'))), mode = firstChild.getAttr('mode'), nolines = typeof mode === 'string' && mode.toLowerCase() === 'nolines', padding = nolines ? 9 : 43;
@@ -33,12 +33,15 @@ 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.IncludeToken = void 0;
38
41
  const lint_1 = require("../../util/lint");
39
42
  const rect_1 = require("../../lib/rect");
40
43
  const hidden_1 = require("../../mixin/hidden");
41
- const index_1 = require("../../index");
44
+ const index_1 = __importDefault(require("../../index"));
42
45
  const index_2 = require("./index");
43
46
  /* NOT FOR BROWSER */
44
47
  const debug_1 = require("../../util/debug");
@@ -33,13 +33,16 @@ 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.TagPairToken = void 0;
38
41
  const index_1 = require("../index");
39
42
  /* NOT FOR BROWSER */
40
43
  const constants_1 = require("../../util/constants");
41
44
  const fixed_1 = require("../../mixin/fixed");
42
- const index_2 = require("../../index");
45
+ const index_2 = __importDefault(require("../../index"));
43
46
  /* NOT FOR BROWSER END */
44
47
  /**
45
48
  * Paired tags
@@ -1,9 +1,8 @@
1
- import Parser from '../index';
2
1
  import { Token } from './index';
3
2
  import { ParameterToken } from './parameter';
4
3
  import { AtomToken } from './atom';
5
4
  import { SyntaxToken } from './syntax';
6
- import type { LintError } from '../base';
5
+ import type { Config, LintError } from '../base';
7
6
  declare type Child = AtomToken | SyntaxToken;
8
7
  /**
9
8
  * template or magic word
@@ -30,7 +29,7 @@ export declare abstract class TranscludeToken extends Token {
30
29
  * @param parts 参数各部分
31
30
  * @throws `SyntaxError` 非法的模板名称
32
31
  */
33
- constructor(title: string, parts: ([string] | [string | number, string])[], config?: Parser.Config, accum?: Token[]);
32
+ constructor(title: string, parts: ([string] | [string | number, string])[], config: Config, accum?: Token[]);
34
33
  /**
35
34
  * Set the transclusion modifier
36
35
  *
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.TranscludeToken = void 0;
4
7
  const string_1 = require("../util/string");
@@ -6,12 +9,12 @@ const lint_1 = require("../util/lint");
6
9
  const debug_1 = require("../util/debug");
7
10
  const constants_1 = require("../util/constants");
8
11
  const rect_1 = require("../lib/rect");
9
- const index_1 = require("../index");
10
- const index_2 = require("./index");
12
+ const index_1 = require("./index");
11
13
  const parameter_1 = require("./parameter");
12
14
  const atom_1 = require("./atom");
13
15
  const syntax_1 = require("./syntax");
14
16
  /* NOT FOR BROWSER */
17
+ const index_2 = __importDefault(require("../index"));
15
18
  const basicMagicWords = new Map([['=', '='], ['!', '|']]);
16
19
  /**
17
20
  * template or magic word
@@ -19,7 +22,7 @@ const basicMagicWords = new Map([['=', '='], ['!', '|']]);
19
22
  * 模板或魔术字
20
23
  * @classdesc `{childNodes: [AtomToken|SyntaxToken, ...AtomToken[], ...ParameterToken[]]}`
21
24
  */
22
- class TranscludeToken extends index_2.Token {
25
+ class TranscludeToken extends index_1.Token {
23
26
  modifier = '';
24
27
  #type = 'template';
25
28
  #raw = false;
@@ -47,7 +50,7 @@ class TranscludeToken extends index_2.Token {
47
50
  * @param parts 参数各部分
48
51
  * @throws `SyntaxError` 非法的模板名称
49
52
  */
50
- constructor(title, parts, config = index_1.default.getConfig(), accum = []) {
53
+ constructor(title, parts, config, accum = []) {
51
54
  let heading;
52
55
  const m = /^(?:\s|\0\d+[cn]\x7F)*\0(\d+)h\x7F(?:\s|\0\d+[cn]\x7F)*/u.exec(title);
53
56
  if (m) {
@@ -107,7 +110,7 @@ class TranscludeToken extends index_2.Token {
107
110
  if (!this.normalizeTitle(name, 10, true, true).valid) {
108
111
  accum.pop();
109
112
  /* NOT FOR BROWSER */
110
- index_1.default.debug(`Invalid template name: ${(0, string_1.noWrap)(name)}`);
113
+ index_2.default.debug(`Invalid template name: ${(0, string_1.noWrap)(name)}`);
111
114
  /* NOT FOR BROWSER END */
112
115
  throw new SyntaxError('Invalid template name');
113
116
  }
@@ -122,7 +125,8 @@ class TranscludeToken extends index_2.Token {
122
125
  }
123
126
  const templateLike = this.isTemplate();
124
127
  let i = 1;
125
- for (const [j, part] of parts.entries()) {
128
+ for (let j = 0; j < parts.length; j++) {
129
+ const part = parts[j];
126
130
  if (!(templateLike || this.name === 'switch' && j > 0 || this.name === 'tag' && j > 1)) {
127
131
  part[0] = part.join('=');
128
132
  part.length = 1;
@@ -169,8 +173,9 @@ class TranscludeToken extends index_2.Token {
169
173
  }
170
174
  /** 获取模板或模块名 */
171
175
  #getTitle() {
172
- const isTemplate = this.type === 'template';
173
- return this.normalizeTitle(this.childNodes[isTemplate ? 0 : 1].toString(true), isTemplate ? 10 : 828, true);
176
+ const isTemplate = this.type === 'template', title = this.normalizeTitle(this.childNodes[isTemplate ? 0 : 1].toString(true), isTemplate ? 10 : 828, true);
177
+ title.fragment = undefined;
178
+ return title;
174
179
  }
175
180
  /**
176
181
  * Get the module name and module function name
@@ -328,11 +333,11 @@ class TranscludeToken extends index_2.Token {
328
333
  /* NOT FOR BROWSER END */
329
334
  for (let i = added ? args.indexOf(addedToken) : addedToken - 1; i < args.length; i++) {
330
335
  const token = args[i], { name } = token, newName = String(i + 1);
331
- if (name !== newName) {
336
+ if (name !== newName || token === addedToken) {
332
337
  token.setAttribute('name', newName);
333
338
  this.getArgs(newName, false, false).add(token);
334
339
  /* NOT FOR BROWSER */
335
- if (name) {
340
+ if (name && token !== addedToken) {
336
341
  this.getArgs(name, false, false).delete(token);
337
342
  }
338
343
  }
@@ -471,7 +476,7 @@ class TranscludeToken extends index_2.Token {
471
476
  const [first, ...cloned] = this.cloneChildNodes(), config = this.getAttribute('config');
472
477
  return debug_1.Shadow.run(() => {
473
478
  // @ts-expect-error abstract class
474
- const token = new TranscludeToken(this.type === 'template' ? 'T' : first.text(), [], config);
479
+ const token = new TranscludeToken(this.type === 'template' ? 'T' : `${first.text()}:`, [], config);
475
480
  if (this.#raw) {
476
481
  token.setModifier(this.modifier);
477
482
  }
@@ -479,7 +484,11 @@ class TranscludeToken extends index_2.Token {
479
484
  token.setAttribute('modifier', this.modifier);
480
485
  }
481
486
  token.firstChild.safeReplaceWith(first);
487
+ if (this.type === 'magic-word') {
488
+ token.removeAt(1);
489
+ }
482
490
  token.append(...cloned);
491
+ token.afterBuild();
483
492
  return token;
484
493
  });
485
494
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.undo = exports.typeError = exports.mixin = exports.setChildNodes = exports.isToken = exports.Shadow = void 0;
3
+ exports.undo = exports.mixin = exports.setChildNodes = exports.isToken = exports.Shadow = void 0;
4
4
  exports.Shadow = {
5
5
  running: false,
6
6
  /** @private */
@@ -65,18 +65,6 @@ const mixin = (target, source) => {
65
65
  };
66
66
  exports.mixin = mixin;
67
67
  /* NOT FOR BROWSER */
68
- /* istanbul ignore next */
69
- /**
70
- * 定制TypeError消息
71
- * @param {Function} Constructor 类
72
- * @param method
73
- * @param args 可接受的参数类型
74
- * @throws `TypeError`
75
- */
76
- const typeError = ({ name }, method, ...args) => {
77
- throw new TypeError(`${name}.${method} method only accepts ${args.join('、')} as input parameters!`);
78
- };
79
- exports.typeError = typeError;
80
68
  /**
81
69
  * 撤销最近一次Mutation
82
70
  * @param e 事件