wikilint 2.30.0 → 2.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +1 -1
- package/dist/base.d.mts +4 -4
- package/dist/base.d.ts +4 -4
- package/dist/base.js +1 -1
- package/dist/base.mjs +2 -2
- package/dist/bin/config.js +1 -1
- package/dist/index.js +1 -1
- package/dist/internal.d.ts +1 -0
- package/dist/lib/element.d.ts +1 -1
- package/dist/lib/element.js +4 -0
- package/dist/lib/lintConfig.js +5 -1
- package/dist/parser/commentAndExt.js +1 -1
- package/dist/parser/hrAndDoubleUnderscore.js +9 -8
- package/dist/src/arg.js +7 -0
- package/dist/src/converterFlags.js +2 -2
- package/dist/src/converterRule.js +89 -38
- package/dist/src/extLink.js +1 -1
- package/dist/src/hidden.js +2 -1
- package/dist/src/imageParameter.js +189 -138
- package/dist/src/index.js +4 -6
- package/dist/src/link/file.js +1 -1
- package/dist/src/link/galleryImage.js +1 -1
- package/dist/src/link/index.js +1 -1
- package/dist/src/nowiki/index.js +1 -1
- package/dist/src/nowiki/list.js +1 -3
- package/dist/src/nowiki/quote.d.ts +2 -2
- package/dist/src/nowiki/quote.js +3 -3
- package/dist/src/table/base.js +1 -2
- package/dist/src/tag/html.js +2 -3
- package/dist/src/tag/index.js +6 -14
- package/dist/src/tag/tvar.js +2 -1
- package/dist/src/tagPair/ext.js +1 -1
- package/dist/src/tagPair/translate.d.ts +1 -0
- package/dist/src/transclude.d.ts +6 -0
- package/dist/src/transclude.js +21 -8
- package/dist/util/constants.js +4 -2
- package/dist/util/string.js +1 -1
- package/i18n/en.json +1 -0
- package/i18n/zh-hans.json +1 -0
- package/i18n/zh-hant.json +1 -0
- package/package.json +8 -4
package/bin/cli.js
CHANGED
package/dist/base.d.mts
CHANGED
|
@@ -16,7 +16,7 @@ export interface Config {
|
|
|
16
16
|
readonly articlePath?: string;
|
|
17
17
|
}
|
|
18
18
|
export type ConfigData = Omit<Config, 'excludes'>;
|
|
19
|
-
export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'tvar' | 'tvar-name' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | '
|
|
19
|
+
export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'tvar' | 'tvar-name' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'imagemap-link';
|
|
20
20
|
export declare const stages: {
|
|
21
21
|
redirect: number;
|
|
22
22
|
onlyinclude: number;
|
|
@@ -42,10 +42,9 @@ export declare const stages: {
|
|
|
42
42
|
list: number;
|
|
43
43
|
dd: number;
|
|
44
44
|
converter: number;
|
|
45
|
-
'list-range': number;
|
|
46
45
|
};
|
|
47
46
|
export type Stage = keyof typeof stages;
|
|
48
|
-
export declare const rules: readonly ["bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "invalid-url", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "syntax-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext", "invalid-css", "invalid-math"];
|
|
47
|
+
export declare const rules: readonly ["arg-in-ext", "bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "invalid-url", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "syntax-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext", "invalid-css", "invalid-math"];
|
|
49
48
|
export declare namespace LintError {
|
|
50
49
|
type Severity = 'error' | 'warning';
|
|
51
50
|
type Rule = typeof rules[number];
|
|
@@ -285,7 +284,8 @@ export interface LintConfiguration extends FullLintConfig {
|
|
|
285
284
|
getSeverity(rule: LintError.Rule, key?: string): LintError.Severity | false;
|
|
286
285
|
}
|
|
287
286
|
export interface Parser {
|
|
288
|
-
config:
|
|
287
|
+
config: string | // eslint-disable-line @stylistic/operator-linebreak
|
|
288
|
+
ConfigData;
|
|
289
289
|
i18n: Record<string, string> | string | undefined;
|
|
290
290
|
/** @since v1.22.0 */
|
|
291
291
|
lintConfig: LintConfig;
|
package/dist/base.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface Config {
|
|
|
16
16
|
readonly articlePath?: string;
|
|
17
17
|
}
|
|
18
18
|
export type ConfigData = Omit<Config, 'excludes'>;
|
|
19
|
-
export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'tvar' | 'tvar-name' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | '
|
|
19
|
+
export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'tvar' | 'tvar-name' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'imagemap-link';
|
|
20
20
|
export declare const stages: {
|
|
21
21
|
redirect: number;
|
|
22
22
|
onlyinclude: number;
|
|
@@ -42,10 +42,9 @@ export declare const stages: {
|
|
|
42
42
|
list: number;
|
|
43
43
|
dd: number;
|
|
44
44
|
converter: number;
|
|
45
|
-
'list-range': number;
|
|
46
45
|
};
|
|
47
46
|
export type Stage = keyof typeof stages;
|
|
48
|
-
export declare const rules: readonly ["bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "invalid-url", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "syntax-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext", "invalid-css", "invalid-math"];
|
|
47
|
+
export declare const rules: readonly ["arg-in-ext", "bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "invalid-url", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "syntax-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext", "invalid-css", "invalid-math"];
|
|
49
48
|
export declare namespace LintError {
|
|
50
49
|
type Severity = 'error' | 'warning';
|
|
51
50
|
type Rule = typeof rules[number];
|
|
@@ -285,7 +284,8 @@ export interface LintConfiguration extends FullLintConfig {
|
|
|
285
284
|
getSeverity(rule: LintError.Rule, key?: string): LintError.Severity | false;
|
|
286
285
|
}
|
|
287
286
|
export interface Parser {
|
|
288
|
-
config:
|
|
287
|
+
config: string | // eslint-disable-line @stylistic/operator-linebreak
|
|
288
|
+
ConfigData;
|
|
289
289
|
i18n: Record<string, string> | string | undefined;
|
|
290
290
|
/** @since v1.22.0 */
|
|
291
291
|
lintConfig: LintConfig;
|
package/dist/base.js
CHANGED
|
@@ -27,13 +27,13 @@ exports.stages = (() => {
|
|
|
27
27
|
list: 10,
|
|
28
28
|
dd: 10,
|
|
29
29
|
converter: 11,
|
|
30
|
-
'list-range': 11,
|
|
31
30
|
};
|
|
32
31
|
Object.setPrototypeOf(obj, null);
|
|
33
32
|
return obj;
|
|
34
33
|
})();
|
|
35
34
|
exports.rules = (() => {
|
|
36
35
|
const arr = [
|
|
36
|
+
'arg-in-ext',
|
|
37
37
|
'bold-header',
|
|
38
38
|
'format-leakage',
|
|
39
39
|
'fostered-content',
|
package/dist/base.mjs
CHANGED
|
@@ -23,14 +23,14 @@ const stages = /* @__PURE__ */ (() => {
|
|
|
23
23
|
"magic-link": 9,
|
|
24
24
|
list: 10,
|
|
25
25
|
dd: 10,
|
|
26
|
-
converter: 11
|
|
27
|
-
"list-range": 11
|
|
26
|
+
converter: 11
|
|
28
27
|
};
|
|
29
28
|
Object.setPrototypeOf(obj, null);
|
|
30
29
|
return obj;
|
|
31
30
|
})();
|
|
32
31
|
const rules = /* @__PURE__ */ (() => {
|
|
33
32
|
const arr = [
|
|
33
|
+
"arg-in-ext",
|
|
34
34
|
"bold-header",
|
|
35
35
|
"format-leakage",
|
|
36
36
|
"fostered-content",
|
package/dist/bin/config.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -134,7 +134,7 @@ const Parser = {
|
|
|
134
134
|
root.type = 'root';
|
|
135
135
|
root.pageName = opt?.page;
|
|
136
136
|
root.parseOnce(0, include).parseOnce();
|
|
137
|
-
const t = new Title(root.toString(), defaultNs, config, opt);
|
|
137
|
+
const t = new Title(root.firstChild.toString(), defaultNs, config, opt);
|
|
138
138
|
root.build();
|
|
139
139
|
for (const key of ['main', 'fragment']) {
|
|
140
140
|
const str = t[key];
|
package/dist/internal.d.ts
CHANGED
|
@@ -46,3 +46,4 @@ export type { ImagemapLinkToken } from './src/imagemapLink';
|
|
|
46
46
|
export type { ImagemapToken } from './src/multiLine/imagemap';
|
|
47
47
|
export type { CommentedToken } from './src/commented';
|
|
48
48
|
export type { TranslateToken } from './src/tagPair/translate';
|
|
49
|
+
export type { TvarToken } from './src/tag/tvar';
|
package/dist/lib/element.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AstNode } from './node';
|
|
2
|
-
import type { LintError } from '../base';
|
|
2
|
+
import type { TokenTypes, LintError } from '../base';
|
|
3
3
|
import type { ElementLike } from '../mixin/elementLike';
|
|
4
4
|
import type { AstNodes, Token } from '../internal';
|
|
5
5
|
export interface CaretPosition {
|
package/dist/lib/element.js
CHANGED
package/dist/lib/lintConfig.js
CHANGED
|
@@ -12,6 +12,7 @@ const dict = new Map([
|
|
|
12
12
|
['error', 'error'],
|
|
13
13
|
]);
|
|
14
14
|
const defaultLintRuleConfig = {
|
|
15
|
+
'arg-in-ext': 1,
|
|
15
16
|
'bold-header': [
|
|
16
17
|
1,
|
|
17
18
|
{
|
|
@@ -268,11 +269,14 @@ const set = (obj, key, value) => {
|
|
|
268
269
|
/* istanbul ignore next */
|
|
269
270
|
throw new RangeError(`Invalid lint config for ${key}: ${JSON.stringify(value)}`);
|
|
270
271
|
};
|
|
272
|
+
const clone = typeof structuredClone === 'function'
|
|
273
|
+
? structuredClone
|
|
274
|
+
: /* istanbul ignore next */ (obj) => JSON.parse(JSON.stringify(obj));
|
|
271
275
|
/** 语法规则设置 */
|
|
272
276
|
class LintRuleConfiguration {
|
|
273
277
|
/** @param config 语法规则设置 */
|
|
274
278
|
constructor(config) {
|
|
275
|
-
Object.assign(this,
|
|
279
|
+
Object.assign(this, clone(defaultLintRuleConfig));
|
|
276
280
|
if (!config) {
|
|
277
281
|
return;
|
|
278
282
|
}
|
|
@@ -44,7 +44,7 @@ const parseCommentAndExt = (wikitext, config, accum, includeOnly) => {
|
|
|
44
44
|
str += `\0${accum.length - 1}n\x7F`;
|
|
45
45
|
};
|
|
46
46
|
while (i !== -1 && j !== -1) {
|
|
47
|
-
const token = `\0${accum.length}
|
|
47
|
+
const token = `\0${accum.length}g\x7F`;
|
|
48
48
|
new onlyinclude_1.OnlyincludeToken(wikitext.slice(i + length, j), config, accum);
|
|
49
49
|
if (i > 0) {
|
|
50
50
|
noinclude(wikitext.slice(0, i));
|
|
@@ -15,19 +15,20 @@ const parseHrAndDoubleUnderscore = ({ firstChild: { data }, type, name }, config
|
|
|
15
15
|
const { doubleUnderscore: [insensitive, sensitive, aliases] } = config, all = [...insensitive, ...sensitive];
|
|
16
16
|
config.insensitiveDoubleUnderscore ??= new Set(insensitive.filter(cm_util_1.isUnderscore));
|
|
17
17
|
config.sensitiveDoubleUnderscore ??= new Set(sensitive.filter(cm_util_1.isUnderscore));
|
|
18
|
-
config.regexHrAndDoubleUnderscore ??= new RegExp(
|
|
18
|
+
config.regexHrAndDoubleUnderscore ??= new RegExp(String.raw `^((?:\0\d+[cno]\x7F)*)(-{4,})|__(${all.filter(cm_util_1.isUnderscore).join('|')})__|_{2}(${all.filter(s => !(0, cm_util_1.isUnderscore)(s)).map(s => s.slice(2, -2)).join('|')})_{2}`, 'gimu');
|
|
19
19
|
if (type !== 'root' && (type !== 'ext-inner' || name !== 'poem')) {
|
|
20
20
|
data = `\0${data}`;
|
|
21
21
|
}
|
|
22
|
-
data = data.replace(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
data = data.replace(config.regexHrAndDoubleUnderscore, (m, p1, p2, p3, p4) => {
|
|
23
|
+
if (p2) {
|
|
24
|
+
// @ts-expect-error abstract class
|
|
25
|
+
new hr_1.HrToken(p2, config, accum);
|
|
26
|
+
return `${p1}\0${accum.length - 1}r\x7F`;
|
|
27
|
+
}
|
|
28
|
+
const key = p3 ?? p4, caseSensitive = config.sensitiveDoubleUnderscore.has(key), lc = key.toLowerCase(), caseInsensitive = config.insensitiveDoubleUnderscore.has(lc);
|
|
28
29
|
if (caseSensitive || caseInsensitive) {
|
|
29
30
|
// @ts-expect-error abstract class
|
|
30
|
-
new doubleUnderscore_1.DoubleUnderscoreToken(key, caseSensitive, Boolean(
|
|
31
|
+
new doubleUnderscore_1.DoubleUnderscoreToken(key, caseSensitive, Boolean(p4), config, accum);
|
|
31
32
|
return `\0${accum.length - 1}${caseInsensitive && (aliases?.[lc] ?? /* istanbul ignore next */ lc) === 'toc' ? 'u' : 'n'}\x7F`;
|
|
32
33
|
}
|
|
33
34
|
return m;
|
package/dist/src/arg.js
CHANGED
|
@@ -146,6 +146,13 @@ let ArgToken = (() => {
|
|
|
146
146
|
}
|
|
147
147
|
errors.push(e);
|
|
148
148
|
}
|
|
149
|
+
const ext = this.closest('ext');
|
|
150
|
+
if (ext) {
|
|
151
|
+
const rule = 'arg-in-ext', severity = lintConfig.getSeverity(rule, ext.name);
|
|
152
|
+
if (severity) {
|
|
153
|
+
errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'argument-in-ext', severity));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
149
156
|
return errors;
|
|
150
157
|
}
|
|
151
158
|
}
|
|
@@ -41,6 +41,7 @@ exports.ConverterFlagsToken = void 0;
|
|
|
41
41
|
const lint_1 = require("../util/lint");
|
|
42
42
|
const rect_1 = require("../lib/rect");
|
|
43
43
|
const gapped_1 = require("../mixin/gapped");
|
|
44
|
+
const noEscape_1 = require("../mixin/noEscape");
|
|
44
45
|
const index_1 = __importDefault(require("../index"));
|
|
45
46
|
const index_2 = require("./index");
|
|
46
47
|
const atom_1 = require("./atom");
|
|
@@ -52,7 +53,7 @@ const definedFlags = new Set(['A', 'T', 'R', 'D', '-', 'H', 'N']);
|
|
|
52
53
|
* @classdesc `{childNodes: AtomToken[]}`
|
|
53
54
|
*/
|
|
54
55
|
let ConverterFlagsToken = (() => {
|
|
55
|
-
let _classDecorators = [(0, gapped_1.gapped)()];
|
|
56
|
+
let _classDecorators = [(0, gapped_1.gapped)(), noEscape_1.noEscape];
|
|
56
57
|
let _classDescriptor;
|
|
57
58
|
let _classExtraInitializers = [];
|
|
58
59
|
let _classThis;
|
|
@@ -108,7 +109,6 @@ let ConverterFlagsToken = (() => {
|
|
|
108
109
|
/** @private */
|
|
109
110
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
110
111
|
isInvalidFlag(flag, variant, unknown, valid) {
|
|
111
|
-
// @ts-expect-error flag is string
|
|
112
112
|
return Boolean(flag) && !variant.has(flag) && !unknown.has(flag) && (variant.size > 0 || !valid.has(flag));
|
|
113
113
|
}
|
|
114
114
|
/** @private */
|
|
@@ -1,10 +1,45 @@
|
|
|
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
|
};
|
|
5
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
40
|
exports.ConverterRuleToken = void 0;
|
|
7
41
|
const constants_1 = require("../util/constants");
|
|
42
|
+
const noEscape_1 = require("../mixin/noEscape");
|
|
8
43
|
const index_1 = __importDefault(require("../index"));
|
|
9
44
|
const index_2 = require("./index");
|
|
10
45
|
const atom_1 = require("./atom");
|
|
@@ -27,45 +62,61 @@ const getRuleFromTo = (text, type, config, accum) => {
|
|
|
27
62
|
* 转换规则
|
|
28
63
|
* @classdesc `{childNodes: [Token?, AtomToken?, Token]}`
|
|
29
64
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
65
|
+
let ConverterRuleToken = (() => {
|
|
66
|
+
let _classDecorators = [noEscape_1.noEscape];
|
|
67
|
+
let _classDescriptor;
|
|
68
|
+
let _classExtraInitializers = [];
|
|
69
|
+
let _classThis;
|
|
70
|
+
let _classSuper = index_2.Token;
|
|
71
|
+
var ConverterRuleToken = class extends _classSuper {
|
|
72
|
+
static { _classThis = this; }
|
|
73
|
+
static {
|
|
74
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
75
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
76
|
+
ConverterRuleToken = _classThis = _classDescriptor.value;
|
|
77
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
78
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
79
|
+
}
|
|
80
|
+
get type() {
|
|
81
|
+
return 'converter-rule';
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* @param rule 转换规则
|
|
85
|
+
* @param hasColon 是否带有":"
|
|
86
|
+
*/
|
|
87
|
+
constructor(rule, hasColon = true, config = index_1.default.getConfig(), accum = []) {
|
|
88
|
+
super(undefined, config, accum, {});
|
|
89
|
+
const i = rule.indexOf(':'), j = rule.slice(0, i).indexOf('=>'), v = j === -1 ? rule.slice(0, i) : rule.slice(j + 2, i);
|
|
90
|
+
if (hasColon && config.variants.includes(v.trim().toLowerCase())) {
|
|
91
|
+
super.insertAt(new atom_1.AtomToken(v, 'converter-rule-variant', config, accum));
|
|
92
|
+
super.insertAt(getRuleFromTo(rule.slice(i + 1), 'to', config, accum));
|
|
93
|
+
if (j !== -1) {
|
|
94
|
+
super.insertAt(getRuleFromTo(rule.slice(0, j), 'from', config, accum), 0);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
super.insertAt(getRuleFromTo(rule, 'to', config, accum));
|
|
46
99
|
}
|
|
47
100
|
}
|
|
48
|
-
|
|
49
|
-
|
|
101
|
+
/** @private */
|
|
102
|
+
toString(skip) {
|
|
103
|
+
const { childNodes, firstChild, lastChild } = this;
|
|
104
|
+
return childNodes.length === 3
|
|
105
|
+
? `${firstChild.toString(skip)}=>${childNodes[1].toString(skip)}:${lastChild.toString(skip)}`
|
|
106
|
+
: super.toString(skip, ':');
|
|
50
107
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
/** @private */
|
|
67
|
-
getGaps(i) {
|
|
68
|
-
return i === 0 && this.length === 3 ? 2 : 1;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
108
|
+
/** @private */
|
|
109
|
+
text() {
|
|
110
|
+
const { childNodes, firstChild, lastChild } = this;
|
|
111
|
+
return childNodes.length === 3
|
|
112
|
+
? `${firstChild.text()}=>${childNodes[1].text()}:${lastChild.text()}`
|
|
113
|
+
: super.text(':');
|
|
114
|
+
}
|
|
115
|
+
/** @private */
|
|
116
|
+
getGaps(i) {
|
|
117
|
+
return i === 0 && this.length === 3 ? 2 : 1;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
return ConverterRuleToken = _classThis;
|
|
121
|
+
})();
|
|
71
122
|
exports.ConverterRuleToken = ConverterRuleToken;
|
package/dist/src/extLink.js
CHANGED
|
@@ -108,7 +108,7 @@ let ExtLinkToken = (() => {
|
|
|
108
108
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
109
109
|
LINT: {
|
|
110
110
|
const errors = super.lint(start, re), rule = 'var-anchor', s = index_1.default.lintConfig.getSeverity(rule, 'extLink');
|
|
111
|
-
if (s && this.length === 1 && this.
|
|
111
|
+
if (s && this.length === 1 && this.isInside('heading-title')) {
|
|
112
112
|
errors.push((0, lint_1.generateForSelf)(this, { start }, rule, 'variable-anchor', s));
|
|
113
113
|
}
|
|
114
114
|
return errors;
|
package/dist/src/hidden.js
CHANGED
|
@@ -36,6 +36,7 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
37
|
exports.HiddenToken = void 0;
|
|
38
38
|
const hidden_1 = require("../mixin/hidden");
|
|
39
|
+
const noEscape_1 = require("../mixin/noEscape");
|
|
39
40
|
const index_1 = require("./index");
|
|
40
41
|
/**
|
|
41
42
|
* invisible token
|
|
@@ -43,7 +44,7 @@ const index_1 = require("./index");
|
|
|
43
44
|
* 不可见的节点
|
|
44
45
|
*/
|
|
45
46
|
let HiddenToken = (() => {
|
|
46
|
-
let _classDecorators = [(0, hidden_1.hiddenToken)()];
|
|
47
|
+
let _classDecorators = [(0, hidden_1.hiddenToken)(), noEscape_1.noEscape];
|
|
47
48
|
let _classDescriptor;
|
|
48
49
|
let _classExtraInitializers = [];
|
|
49
50
|
let _classThis;
|