wikiparser-node 1.4.2 → 1.4.3

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 (103) hide show
  1. package/dist/addon/table.js +5 -1
  2. package/dist/base.d.ts +6 -1
  3. package/dist/index.d.ts +0 -2
  4. package/dist/index.js +3 -3
  5. package/dist/lib/element.d.ts +3 -2
  6. package/dist/lib/element.js +20 -13
  7. package/dist/lib/node.js +13 -10
  8. package/dist/lib/text.js +3 -3
  9. package/dist/lib/title.js +4 -12
  10. package/dist/mixin/attributesParent.d.ts +32 -2
  11. package/dist/mixin/attributesParent.js +14 -25
  12. package/dist/mixin/fixed.d.ts +2 -1
  13. package/dist/mixin/fixed.js +3 -1
  14. package/dist/mixin/flagsParent.d.ts +28 -17
  15. package/dist/mixin/flagsParent.js +12 -25
  16. package/dist/mixin/magicLinkParent.d.ts +14 -8
  17. package/dist/mixin/magicLinkParent.js +7 -8
  18. package/dist/mixin/singleLine.d.ts +2 -1
  19. package/dist/mixin/singleLine.js +3 -2
  20. package/dist/mixin/sol.d.ts +2 -4
  21. package/dist/mixin/sol.js +8 -6
  22. package/dist/mixin/syntax.d.ts +5 -2
  23. package/dist/mixin/syntax.js +14 -18
  24. package/dist/parser/links.js +1 -3
  25. package/dist/src/arg.d.ts +4 -4
  26. package/dist/src/arg.js +4 -4
  27. package/dist/src/attribute.d.ts +9 -7
  28. package/dist/src/attribute.js +271 -218
  29. package/dist/src/attributes.d.ts +3 -3
  30. package/dist/src/attributes.js +0 -1
  31. package/dist/src/converter.d.ts +7 -2
  32. package/dist/src/converter.js +113 -64
  33. package/dist/src/converterFlags.d.ts +5 -5
  34. package/dist/src/converterFlags.js +0 -1
  35. package/dist/src/converterRule.d.ts +5 -5
  36. package/dist/src/converterRule.js +0 -1
  37. package/dist/src/extLink.d.ts +7 -2
  38. package/dist/src/extLink.js +159 -110
  39. package/dist/src/gallery.d.ts +5 -5
  40. package/dist/src/gallery.js +0 -1
  41. package/dist/src/heading.d.ts +8 -8
  42. package/dist/src/heading.js +172 -125
  43. package/dist/src/html.d.ts +8 -5
  44. package/dist/src/html.js +263 -214
  45. package/dist/src/imageParameter.d.ts +2 -2
  46. package/dist/src/imageParameter.js +1 -0
  47. package/dist/src/imagemap.d.ts +5 -5
  48. package/dist/src/imagemap.js +4 -10
  49. package/dist/src/imagemapLink.d.ts +7 -4
  50. package/dist/src/imagemapLink.js +75 -26
  51. package/dist/src/index.js +3 -4
  52. package/dist/src/link/base.d.ts +2 -2
  53. package/dist/src/link/base.js +1 -4
  54. package/dist/src/link/file.d.ts +1 -1
  55. package/dist/src/link/file.js +0 -1
  56. package/dist/src/link/galleryImage.d.ts +2 -1
  57. package/dist/src/link/galleryImage.js +136 -88
  58. package/dist/src/link/index.js +0 -1
  59. package/dist/src/magicLink.d.ts +11 -3
  60. package/dist/src/magicLink.js +170 -120
  61. package/dist/src/nested.d.ts +5 -5
  62. package/dist/src/nested.js +1 -0
  63. package/dist/src/nowiki/base.d.ts +6 -2
  64. package/dist/src/nowiki/base.js +79 -28
  65. package/dist/src/nowiki/comment.d.ts +0 -2
  66. package/dist/src/nowiki/comment.js +0 -9
  67. package/dist/src/nowiki/doubleUnderscore.js +88 -38
  68. package/dist/src/nowiki/hr.d.ts +1 -4
  69. package/dist/src/nowiki/hr.js +53 -4
  70. package/dist/src/nowiki/index.d.ts +2 -2
  71. package/dist/src/nowiki/index.js +1 -0
  72. package/dist/src/nowiki/list.d.ts +1 -4
  73. package/dist/src/nowiki/list.js +88 -39
  74. package/dist/src/nowiki/listBase.d.ts +1 -1
  75. package/dist/src/nowiki/listBase.js +52 -2
  76. package/dist/src/nowiki/quote.d.ts +3 -3
  77. package/dist/src/nowiki/quote.js +102 -54
  78. package/dist/src/paramTag/index.d.ts +5 -5
  79. package/dist/src/paramTag/index.js +2 -1
  80. package/dist/src/parameter.d.ts +11 -8
  81. package/dist/src/parameter.js +225 -176
  82. package/dist/src/pre.d.ts +5 -5
  83. package/dist/src/pre.js +1 -0
  84. package/dist/src/syntax.d.ts +6 -0
  85. package/dist/src/syntax.js +74 -23
  86. package/dist/src/table/base.d.ts +6 -3
  87. package/dist/src/table/base.js +100 -49
  88. package/dist/src/table/index.d.ts +6 -3
  89. package/dist/src/table/index.js +5 -9
  90. package/dist/src/table/td.d.ts +9 -5
  91. package/dist/src/table/td.js +270 -217
  92. package/dist/src/table/tr.d.ts +4 -4
  93. package/dist/src/table/tr.js +1 -0
  94. package/dist/src/tagPair/ext.d.ts +6 -3
  95. package/dist/src/tagPair/ext.js +168 -118
  96. package/dist/src/tagPair/include.d.ts +2 -4
  97. package/dist/src/tagPair/include.js +0 -8
  98. package/dist/src/tagPair/index.d.ts +1 -1
  99. package/dist/src/tagPair/index.js +115 -66
  100. package/dist/src/transclude.d.ts +3 -3
  101. package/dist/src/transclude.js +4 -9
  102. package/dist/util/debug.js +0 -2
  103. package/package.json +3 -3
@@ -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.QuoteToken = void 0;
4
38
  const lint_1 = require("../../util/lint");
@@ -7,62 +41,76 @@ const syntax_1 = require("../../mixin/syntax");
7
41
  const index_1 = require("../../index");
8
42
  const base_1 = require("./base");
9
43
  /** `''`和`'''` */
10
- class QuoteToken extends (0, syntax_1.syntax)(base_1.NowikiBaseToken, /^(?:'{5}|'''?)$/u) {
11
- type = 'quote';
12
- /** 是否粗体 */
13
- get bold() {
14
- return this.innerText.length !== 2;
15
- }
16
- /** 是否斜体 */
17
- get italic() {
18
- return this.innerText.length !== 3;
19
- }
20
- /** @override */
21
- lint(start = this.getAbsoluteIndex()) {
22
- const { previousSibling, nextSibling, bold } = this, message = index_1.default.msg('lonely "$1"', `'`), errors = [];
23
- let refError;
24
- if (previousSibling?.type === 'text' && previousSibling.data.endsWith(`'`)) {
25
- refError = (0, lint_1.generateForSelf)(this, { start }, message);
26
- const { startIndex: endIndex, startLine: endLine, startCol: endCol } = refError, [, { length }] = /(?:^|[^'])('+)$/u.exec(previousSibling.data), startIndex = start - length;
27
- errors.push({
28
- ...refError,
29
- startIndex,
30
- endIndex,
31
- startCol: endCol - length,
32
- endLine,
33
- endCol,
34
- });
44
+ let QuoteToken = (() => {
45
+ let _classDecorators = [(0, syntax_1.syntax)(/^(?:'{5}|'''?)$/u)];
46
+ let _classDescriptor;
47
+ let _classExtraInitializers = [];
48
+ let _classThis;
49
+ let _classSuper = base_1.NowikiBaseToken;
50
+ var QuoteToken = class extends _classSuper {
51
+ static { _classThis = this; }
52
+ static {
53
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
54
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
55
+ QuoteToken = _classThis = _classDescriptor.value;
56
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
57
+ __runInitializers(_classThis, _classExtraInitializers);
35
58
  }
36
- if (nextSibling?.type === 'text' && nextSibling.data.startsWith(`'`)) {
37
- refError ??= (0, lint_1.generateForSelf)(this, { start }, message);
38
- const { endIndex: startIndex, endLine: startLine, endCol: startCol } = refError, [{ length }] = /^'+/u.exec(nextSibling.data), endIndex = startIndex + length;
39
- errors.push({
40
- ...refError,
41
- startIndex,
42
- endIndex,
43
- startLine,
44
- startCol,
45
- endCol: startCol + length,
46
- });
59
+ type = 'quote';
60
+ /** 是否粗体 */
61
+ get bold() {
62
+ return this.innerText.length !== 2;
47
63
  }
48
- if (bold && this.closest('heading-title')) {
49
- refError ??= (0, lint_1.generateForSelf)(this, { start }, message);
50
- errors.push({
51
- ...refError,
52
- message: index_1.default.msg('bold in section header'),
53
- severity: 'warning',
54
- });
64
+ /** 是否斜体 */
65
+ get italic() {
66
+ return this.innerText.length !== 3;
55
67
  }
56
- return errors;
57
- }
58
- /** @override */
59
- json() {
60
- return {
61
- ...super.json(),
62
- bold: this.bold,
63
- italic: this.italic,
64
- };
65
- }
66
- }
68
+ /** @override */
69
+ lint(start = this.getAbsoluteIndex()) {
70
+ const { previousSibling, nextSibling, bold } = this, message = index_1.default.msg('lonely "$1"', `'`), errors = [];
71
+ let refError;
72
+ if (previousSibling?.type === 'text' && previousSibling.data.endsWith(`'`)) {
73
+ refError = (0, lint_1.generateForSelf)(this, { start }, message);
74
+ const { startIndex: endIndex, startLine: endLine, startCol: endCol } = refError, [, { length }] = /(?:^|[^'])('+)$/u.exec(previousSibling.data), startIndex = start - length;
75
+ errors.push({
76
+ ...refError,
77
+ startIndex,
78
+ endIndex,
79
+ startCol: endCol - length,
80
+ endLine,
81
+ endCol,
82
+ });
83
+ }
84
+ if (nextSibling?.type === 'text' && nextSibling.data.startsWith(`'`)) {
85
+ refError ??= (0, lint_1.generateForSelf)(this, { start }, message);
86
+ const { endIndex: startIndex, endLine: startLine, endCol: startCol } = refError, [{ length }] = /^'+/u.exec(nextSibling.data), endIndex = startIndex + length;
87
+ errors.push({
88
+ ...refError,
89
+ startIndex,
90
+ endIndex,
91
+ startLine,
92
+ startCol,
93
+ endCol: startCol + length,
94
+ });
95
+ }
96
+ if (bold && this.closest('heading-title')) {
97
+ refError ??= (0, lint_1.generateForSelf)(this, { start }, message);
98
+ errors.push({
99
+ ...refError,
100
+ message: index_1.default.msg('bold in section header'),
101
+ severity: 'warning',
102
+ });
103
+ }
104
+ return errors;
105
+ }
106
+ /** @override */
107
+ json() {
108
+ const json = super.json();
109
+ Object.assign(json, { bold: this.bold, italic: this.italic });
110
+ return json;
111
+ }
112
+ };
113
+ return QuoteToken = _classThis;
114
+ })();
67
115
  exports.QuoteToken = QuoteToken;
68
116
  constants_1.classes['QuoteToken'] = __filename;
@@ -11,16 +11,16 @@ export declare abstract class ParamTagToken extends Token {
11
11
  readonly type = "ext-inner";
12
12
  readonly name: string;
13
13
  readonly childNodes: readonly AtomToken[];
14
- abstract get children(): AtomToken[];
15
14
  abstract get firstChild(): AtomToken | undefined;
16
- abstract get firstElementChild(): AtomToken | undefined;
17
15
  abstract get lastChild(): AtomToken | undefined;
18
- abstract get lastElementChild(): AtomToken | undefined;
19
16
  abstract get nextSibling(): undefined;
20
- abstract get nextElementSibling(): undefined;
21
17
  abstract get previousSibling(): AttributesToken;
22
- abstract get previousElementSibling(): AttributesToken;
23
18
  abstract get parentNode(): ExtToken | undefined;
19
+ abstract get children(): AtomToken[];
20
+ abstract get firstElementChild(): AtomToken | undefined;
21
+ abstract get lastElementChild(): AtomToken | undefined;
22
+ abstract get nextElementSibling(): undefined;
23
+ abstract get previousElementSibling(): AttributesToken;
24
24
  abstract get parentElement(): ExtToken | undefined;
25
25
  /** @class */
26
26
  constructor(wikitext?: string, config?: Parser.Config, accum?: Token[], acceptable?: Acceptable);
@@ -14,10 +14,11 @@ const atom_1 = require("../atom");
14
14
  */
15
15
  class ParamTagToken extends index_2.Token {
16
16
  type = 'ext-inner';
17
+ /* NOT FOR BROWSER END */
17
18
  /** @class */
18
19
  constructor(wikitext, config = index_1.default.getConfig(), accum = [], acceptable = {}) {
19
20
  super(undefined, config, accum, {
20
- SingleLineAtomToken: ':',
21
+ AtomToken: ':',
21
22
  });
22
23
  if (wikitext) {
23
24
  const SingleLineAtomToken = (0, singleLine_1.singleLine)(atom_1.AtomToken);
@@ -1,21 +1,25 @@
1
1
  import Parser from '../index';
2
2
  import { Token } from './index';
3
- import type { LintError } from '../base';
3
+ import type { LintError, AST } from '../base';
4
4
  import type { AtomToken, SyntaxToken, TranscludeToken } from '../internal';
5
+ /**
6
+ * 模板或魔术字参数
7
+ * @classdesc `{childNodes: [Token, Token]}`
8
+ */
5
9
  export declare abstract class ParameterToken extends Token {
6
10
  readonly type = "parameter";
7
11
  readonly name: string;
8
12
  readonly childNodes: readonly [Token, Token];
9
- abstract get children(): [Token, Token];
10
13
  abstract get firstChild(): Token;
11
- abstract get firstElementChild(): Token;
12
14
  abstract get lastChild(): Token;
13
- abstract get lastElementChild(): Token;
14
15
  abstract get parentNode(): TranscludeToken | undefined;
15
- abstract get parentElement(): TranscludeToken | undefined;
16
16
  abstract get nextSibling(): this | undefined;
17
- abstract get nextElementSibling(): this | undefined;
18
17
  abstract get previousSibling(): AtomToken | SyntaxToken | this;
18
+ abstract get children(): [Token, Token];
19
+ abstract get firstElementChild(): Token;
20
+ abstract get lastElementChild(): Token;
21
+ abstract get parentElement(): TranscludeToken | undefined;
22
+ abstract get nextElementSibling(): this | undefined;
19
23
  abstract get previousElementSibling(): AtomToken | SyntaxToken | this;
20
24
  /** 是否是匿名参数 */
21
25
  get anon(): boolean;
@@ -38,7 +42,7 @@ export declare abstract class ParameterToken extends Token {
38
42
  /** @override */
39
43
  print(): string;
40
44
  /** @override */
41
- json(): object;
45
+ json(): AST;
42
46
  /** @override */
43
47
  cloneNode(): this;
44
48
  /**
@@ -64,4 +68,3 @@ export declare abstract class ParameterToken extends Token {
64
68
  /** 转义 `=` */
65
69
  escape(): void;
66
70
  }
67
- export {};