wikilint 2.3.9 → 2.4.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.
Files changed (59) hide show
  1. package/dist/base.d.ts +3 -1
  2. package/dist/bin/declaration.js +27 -0
  3. package/dist/lib/element.d.ts +1 -1
  4. package/dist/lib/element.js +13 -4
  5. package/dist/lib/node.d.ts +1 -2
  6. package/dist/lib/text.d.ts +0 -1
  7. package/dist/mixin/hidden.js +3 -4
  8. package/dist/parser/hrAndDoubleUnderscore.js +3 -3
  9. package/dist/src/arg.d.ts +1 -1
  10. package/dist/src/attribute.d.ts +1 -2
  11. package/dist/src/attributes.d.ts +2 -2
  12. package/dist/src/converter.d.ts +2 -12
  13. package/dist/src/converterFlags.d.ts +1 -2
  14. package/dist/src/converterRule.d.ts +1 -1
  15. package/dist/src/extLink.d.ts +2 -13
  16. package/dist/src/gallery.d.ts +1 -2
  17. package/dist/src/heading.d.ts +1 -2
  18. package/dist/src/hidden.d.ts +1 -7
  19. package/dist/src/hidden.js +1 -1
  20. package/dist/src/html.d.ts +1 -2
  21. package/dist/src/html.js +18 -2
  22. package/dist/src/imageParameter.d.ts +2 -1
  23. package/dist/src/imageParameter.js +8 -0
  24. package/dist/src/imagemap.d.ts +1 -1
  25. package/dist/src/imagemapLink.d.ts +1 -1
  26. package/dist/src/index.d.ts +0 -1
  27. package/dist/src/link/base.d.ts +1 -2
  28. package/dist/src/link/base.js +2 -6
  29. package/dist/src/link/file.d.ts +16 -7
  30. package/dist/src/link/file.js +18 -0
  31. package/dist/src/link/galleryImage.d.ts +0 -3
  32. package/dist/src/link/galleryImage.js +1 -1
  33. package/dist/src/link/index.d.ts +4 -1
  34. package/dist/src/link/index.js +9 -0
  35. package/dist/src/magicLink.d.ts +1 -1
  36. package/dist/src/nested.d.ts +1 -1
  37. package/dist/src/nowiki/base.d.ts +1 -1
  38. package/dist/src/nowiki/comment.d.ts +1 -7
  39. package/dist/src/nowiki/comment.js +1 -1
  40. package/dist/src/nowiki/doubleUnderscore.d.ts +3 -9
  41. package/dist/src/nowiki/doubleUnderscore.js +3 -3
  42. package/dist/src/nowiki/noinclude.d.ts +1 -7
  43. package/dist/src/nowiki/noinclude.js +1 -1
  44. package/dist/src/nowiki/quote.js +9 -1
  45. package/dist/src/paramTag/index.d.ts +1 -1
  46. package/dist/src/parameter.d.ts +1 -1
  47. package/dist/src/pre.d.ts +1 -1
  48. package/dist/src/table/base.d.ts +1 -1
  49. package/dist/src/table/index.d.ts +1 -1
  50. package/dist/src/table/td.d.ts +1 -2
  51. package/dist/src/table/tr.d.ts +1 -1
  52. package/dist/src/tagPair/ext.d.ts +1 -1
  53. package/dist/src/tagPair/include.d.ts +2 -11
  54. package/dist/src/tagPair/include.js +1 -1
  55. package/dist/src/tagPair/index.d.ts +1 -2
  56. package/dist/src/transclude.d.ts +5 -6
  57. package/i18n/zh-hans.json +1 -0
  58. package/i18n/zh-hant.json +1 -0
  59. package/package.json +4 -2
package/dist/base.d.ts CHANGED
@@ -24,7 +24,7 @@ export interface LintError {
24
24
  /** 类似Node */
25
25
  export interface AstNode {
26
26
  type: string;
27
- readonly childNodes: AstNode[];
27
+ readonly childNodes: readonly AstNode[];
28
28
  /** Linter */
29
29
  lint(): LintError[];
30
30
  }
@@ -34,6 +34,8 @@ interface AstElement extends AstNode {
34
34
  export interface Parser {
35
35
  config: string | Config;
36
36
  i18n: string | Record<string, string> | undefined;
37
+ /** 获取解析设置 */
38
+ getConfig(): Config;
37
39
  /**
38
40
  * 解析wikitext
39
41
  * @param include 是否嵌入
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ // eslint-disable-next-line @stylistic/max-len
6
+ const regex = /declare [^\n]+?: \(+abstract new [^\n]+\n(.+)\}\) & typeof (\w+\.)?(\w+)\b.+(export [^\n]+ extends )\w+\b(.+?\n)/isu;
7
+ for (const file of fs.readdirSync('dist/src/', { recursive: true })) {
8
+ if (!file.endsWith('.d.ts')) {
9
+ continue;
10
+ }
11
+ const fullPath = path.join('dist/src', file), content = fs.readFileSync(fullPath, 'utf8');
12
+ if (content.includes('(abstract new ')) {
13
+ // console.log(file);
14
+ fs.writeFileSync(fullPath, content.replace(regex, (_, mixins, parser, base, exp, impl) => {
15
+ const str = `${exp}${base}${impl}${mixins.split(/\n\}\) & \(+abstract new .+/u)
16
+ .map(mixin => mixin.slice(0, mixin.indexOf('toString'))
17
+ .replace(/^[ \t]+(?:$|readonly .+\n)/gmu, ''))
18
+ .join('\n')}`, regex2 = new RegExp(`import \\{\\s*${base}\\b.+?;\n`, 'su');
19
+ let imports = '';
20
+ if (parser && !regex2.test(content)) {
21
+ const original = fs.readFileSync(path.join('src', file.replace(/d\.ts$/u, 'ts')), 'utf8');
22
+ [imports] = regex2.exec(original);
23
+ }
24
+ return imports + str;
25
+ }));
26
+ }
27
+ }
@@ -29,7 +29,7 @@ export declare abstract class AstElement extends AstNode {
29
29
  * 最近的祖先节点
30
30
  * @param selector 选择器
31
31
  */
32
- closest<T extends Token>(selector: string): T | undefined;
32
+ closest<T = Token>(selector: string): T | undefined;
33
33
  /**
34
34
  * 在末尾批量插入子节点
35
35
  * @param elements 插入节点
@@ -52,14 +52,23 @@ class AstElement extends node_1.AstNode {
52
52
  return node;
53
53
  }
54
54
  /**
55
- * 最近的祖先节点
55
+ * 将选择器转化为类型谓词
56
56
  * @param selector 选择器
57
57
  */
58
- closest(selector) {
59
- let { parentNode } = this, condition;
58
+ #getCondition(selector) {
59
+ let condition;
60
60
  const types = new Set(selector.split(',').map(str => str.trim()));
61
61
  // eslint-disable-next-line prefer-const
62
- condition = /** @implements */ (token) => types.has(token.type);
62
+ condition = (token => types.has(token.type));
63
+ return condition;
64
+ }
65
+ /**
66
+ * 最近的祖先节点
67
+ * @param selector 选择器
68
+ */
69
+ closest(selector) {
70
+ const condition = this.#getCondition(selector);
71
+ let { parentNode } = this;
63
72
  while (parentNode) {
64
73
  if (condition(parentNode)) {
65
74
  return parentNode;
@@ -16,10 +16,9 @@ export interface CaretPosition {
16
16
  }
17
17
  /** 类似Node */
18
18
  export declare abstract class AstNode implements AstNodeBase {
19
- #private;
20
19
  type: TokenTypes | 'text';
21
20
  data?: string | undefined;
22
- readonly childNodes: AstNodes[];
21
+ readonly childNodes: readonly AstNodes[];
23
22
  abstract lint(): LintError[];
24
23
  /** 首位子节点 */
25
24
  get firstChild(): AstNodes | undefined;
@@ -2,7 +2,6 @@ import { AstNode } from './node';
2
2
  import type { LintError } from '../base';
3
3
  /** 文本节点 */
4
4
  export declare class AstText extends AstNode {
5
- #private;
6
5
  readonly type = "text";
7
6
  readonly name: undefined;
8
7
  readonly data: string;
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hidden = void 0;
3
+ exports.hiddenToken = void 0;
4
4
  /**
5
5
  * 解析后不可见的类
6
6
  * @param constructor 基类
7
7
  */
8
- const hidden = (constructor) => {
8
+ const hiddenToken = (constructor) => {
9
9
  /** 解析后不可见的类 */
10
10
  class AnyHiddenToken extends constructor {
11
- static hidden = true;
12
11
  /** 没有可见部分 */
13
12
  text() {
14
13
  return '';
@@ -20,4 +19,4 @@ const hidden = (constructor) => {
20
19
  }
21
20
  return AnyHiddenToken;
22
21
  };
23
- exports.hidden = hidden;
22
+ exports.hiddenToken = hiddenToken;
@@ -20,9 +20,9 @@ const parseHrAndDoubleUnderscore = ({ firstChild: { data }, type, name }, config
20
20
  new hr_1.HrToken(m, config, accum);
21
21
  return `${lead}\0${accum.length - 1}r\x7F`;
22
22
  }).replace(new RegExp(`__(${doubleUnderscore.flat().join('|')})__`, 'giu'), (m, p1) => {
23
- const fixed = sensitive.has(p1);
24
- if (fixed || insensitive.has(p1.toLowerCase())) {
25
- new doubleUnderscore_1.DoubleUnderscoreToken(p1, fixed, config, accum);
23
+ const caseSensitive = sensitive.has(p1);
24
+ if (caseSensitive || insensitive.has(p1.toLowerCase())) {
25
+ new doubleUnderscore_1.DoubleUnderscoreToken(p1, caseSensitive, config, accum);
26
26
  return `\0${accum.length - 1}u\x7F`;
27
27
  }
28
28
  return m;
package/dist/src/arg.d.ts CHANGED
@@ -9,7 +9,7 @@ import type { LintError } from '../base';
9
9
  */
10
10
  export declare class ArgToken extends Token {
11
11
  readonly type = "arg";
12
- readonly childNodes: [AtomToken] | [AtomToken, Token, ...HiddenToken[]];
12
+ readonly childNodes: readonly [AtomToken] | readonly [AtomToken, Token, ...HiddenToken[]];
13
13
  abstract get firstChild(): AtomToken;
14
14
  abstract get lastChild(): Token;
15
15
  /** 预设值 */
@@ -9,11 +9,10 @@ export type AttributeTypes = 'ext-attr' | 'html-attr' | 'table-attr';
9
9
  * @classdesc `{childNodes: [AtomToken, Token|AtomToken]}`
10
10
  */
11
11
  export declare class AttributeToken extends Token {
12
- #private;
13
12
  type: AttributeTypes;
14
13
  readonly name: string;
15
14
  readonly tag: string;
16
- readonly childNodes: [AtomToken, Token];
15
+ readonly childNodes: readonly [AtomToken, Token];
17
16
  abstract get firstChild(): AtomToken;
18
17
  abstract get lastChild(): Token;
19
18
  abstract get parentNode(): AttributesToken | undefined;
@@ -13,7 +13,7 @@ declare type AttributesTypes = `${AttributeTypes}s`;
13
13
  export declare class AttributesToken extends Token {
14
14
  type: AttributesTypes;
15
15
  readonly name: string;
16
- readonly childNodes: (AtomToken | AttributeToken)[];
16
+ readonly childNodes: readonly (AtomToken | AttributeToken)[];
17
17
  abstract get firstChild(): AtomToken | AttributeToken | undefined;
18
18
  abstract get lastChild(): AtomToken | AttributeToken | undefined;
19
19
  abstract get parentNode(): ExtToken | HtmlToken | TableToken | TrToken | TdToken | undefined;
@@ -27,7 +27,7 @@ export declare class AttributesToken extends Token {
27
27
  * 所有指定属性名的AttributeToken
28
28
  * @param key 属性名
29
29
  */
30
- getAttrTokens(key?: string): readonly AttributeToken[];
30
+ getAttrTokens(key?: string): AttributeToken[];
31
31
  /**
32
32
  * 指定属性名的最后一个AttributeToken
33
33
  * @param key 属性名
@@ -2,19 +2,9 @@ import * as Parser from '../index';
2
2
  import { Token } from './index';
3
3
  import { ConverterFlagsToken } from './converterFlags';
4
4
  import { ConverterRuleToken } from './converterRule';
5
- declare const ConverterToken_base: (abstract new (...args: any[]) => {
6
- readonly firstChild: Parser.ConverterFlagsToken;
7
- toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
8
- text(separator?: string | undefined): string;
9
- lint(start?: number | undefined): Parser.LintError[];
10
- }) & typeof Parser.Token;
11
- /**
12
- * 转换
13
- * @classdesc `{childNodes: [ConverterFlagsToken, ...ConverterRuleToken]}`
14
- */
15
- export declare class ConverterToken extends ConverterToken_base {
5
+ export declare class ConverterToken extends Token {
16
6
  readonly type = "converter";
17
- readonly childNodes: [ConverterFlagsToken, ...ConverterRuleToken[]];
7
+ readonly childNodes: readonly [ConverterFlagsToken, ...ConverterRuleToken[]];
18
8
  abstract get lastChild(): ConverterFlagsToken | ConverterRuleToken;
19
9
  /**
20
10
  * @param flags 转换类型标记
@@ -8,9 +8,8 @@ import type { ConverterToken, ConverterRuleToken } from '../internal';
8
8
  * @classdesc `{childNodes: ...AtomToken}`
9
9
  */
10
10
  export declare class ConverterFlagsToken extends Token {
11
- #private;
12
11
  readonly type = "converter-flags";
13
- readonly childNodes: AtomToken[];
12
+ readonly childNodes: readonly AtomToken[];
14
13
  abstract get firstChild(): AtomToken | undefined;
15
14
  abstract get lastChild(): AtomToken | undefined;
16
15
  abstract get parentNode(): ConverterToken | undefined;
@@ -8,7 +8,7 @@ import type { ConverterToken, ConverterFlagsToken } from '../internal';
8
8
  */
9
9
  export declare class ConverterRuleToken extends Token {
10
10
  readonly type = "converter-rule";
11
- readonly childNodes: [AtomToken] | [AtomToken, AtomToken] | [AtomToken, AtomToken, AtomToken];
11
+ readonly childNodes: readonly [AtomToken] | readonly [AtomToken, AtomToken] | readonly [AtomToken, AtomToken, AtomToken];
12
12
  abstract get firstChild(): AtomToken;
13
13
  abstract get lastChild(): AtomToken;
14
14
  abstract get parentNode(): ConverterToken | undefined;
@@ -1,20 +1,9 @@
1
1
  import * as Parser from '../index';
2
2
  import { Token } from './index';
3
3
  import { MagicLinkToken } from './magicLink';
4
- declare const ExtLinkToken_base: (abstract new (...args: any[]) => {
5
- readonly firstChild: Parser.MagicLinkToken;
6
- toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
7
- text(separator?: string | undefined): string;
8
- lint(start?: number | undefined): Parser.LintError[];
9
- }) & typeof Parser.Token;
10
- /**
11
- * 外链
12
- * @classdesc `{childNodes: [MagicLinkToken, ?Token]}`
13
- */
14
- export declare class ExtLinkToken extends ExtLinkToken_base {
15
- #private;
4
+ export declare class ExtLinkToken extends Token {
16
5
  readonly type = "ext-link";
17
- readonly childNodes: [MagicLinkToken] | [MagicLinkToken, Token];
6
+ readonly childNodes: readonly [MagicLinkToken] | readonly [MagicLinkToken, Token];
18
7
  abstract get lastChild(): Token;
19
8
  /**
20
9
  * @param url 网址
@@ -9,10 +9,9 @@ import type { AstText, AttributesToken, ExtToken } from '../internal';
9
9
  * @classdesc `{childNodes: ...(GalleryImageToken|NoincludeToken|AstText)}`
10
10
  */
11
11
  export declare class GalleryToken extends Token {
12
- #private;
13
12
  readonly type = "ext-inner";
14
13
  readonly name: 'gallery';
15
- readonly childNodes: (GalleryImageToken | NoincludeToken | AstText)[];
14
+ readonly childNodes: readonly (GalleryImageToken | NoincludeToken | AstText)[];
16
15
  abstract get firstChild(): GalleryImageToken | NoincludeToken | AstText | undefined;
17
16
  abstract get lastChild(): GalleryImageToken | NoincludeToken | AstText | undefined;
18
17
  abstract get nextSibling(): undefined;
@@ -7,9 +7,8 @@ import type { LintError } from '../base';
7
7
  * @classdesc `{childNodes: [Token, SyntaxToken]}`
8
8
  */
9
9
  export declare class HeadingToken extends Token {
10
- #private;
11
10
  readonly type = "heading";
12
- readonly childNodes: [Token, SyntaxToken];
11
+ readonly childNodes: readonly [Token, SyntaxToken];
13
12
  abstract get firstChild(): Token;
14
13
  abstract get lastChild(): SyntaxToken;
15
14
  /** 标题层级 */
@@ -1,13 +1,7 @@
1
1
  import { Token } from './index';
2
- declare const HiddenToken_base: ((abstract new (...args: any[]) => {
2
+ export declare class HiddenToken extends Token {
3
3
  text(): string;
4
4
  lint(): import("..").LintError[];
5
- toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
6
- }) & {
7
- readonly hidden: true;
8
- }) & typeof Token;
9
- /** 不可见的节点 */
10
- export declare class HiddenToken extends HiddenToken_base {
11
5
  readonly type = "hidden";
12
6
  }
13
7
  export {};
@@ -4,7 +4,7 @@ exports.HiddenToken = void 0;
4
4
  const hidden_1 = require("../mixin/hidden");
5
5
  const index_1 = require("./index");
6
6
  /** 不可见的节点 */
7
- class HiddenToken extends (0, hidden_1.hidden)(index_1.Token) {
7
+ class HiddenToken extends (0, hidden_1.hiddenToken)(index_1.Token) {
8
8
  type = 'hidden';
9
9
  }
10
10
  exports.HiddenToken = HiddenToken;
@@ -7,10 +7,9 @@ import type { AttributesToken } from '../internal';
7
7
  * @classdesc `{childNodes: [AttributesToken]}`
8
8
  */
9
9
  export declare class HtmlToken extends Token {
10
- #private;
11
10
  readonly type = "html";
12
11
  readonly name: string;
13
- readonly childNodes: [AttributesToken];
12
+ readonly childNodes: readonly [AttributesToken];
14
13
  abstract get firstChild(): AttributesToken;
15
14
  abstract get lastChild(): AttributesToken;
16
15
  /** 是否是闭合标签 */
package/dist/src/html.js CHANGED
@@ -100,8 +100,16 @@ class HtmlToken extends index_1.Token {
100
100
  const { message: errorMsg } = e;
101
101
  refError ??= (0, lint_1.generateForSelf)(this, { start }, '');
102
102
  const [msg] = errorMsg.split(':'), error = { ...refError, message: Parser.msg(msg) };
103
- if (msg === 'unclosed tag' && !formattingTags.has(this.name)) {
104
- error.severity = 'warning';
103
+ if (msg === 'unclosed tag' && !this.closest('heading-title')) {
104
+ if (formattingTags.has(this.name)) {
105
+ const childNodes = this.parentNode?.childNodes, i = childNodes?.indexOf(this);
106
+ if (!childNodes?.slice(0, i).some(({ type, name }) => type === 'html' && name === this.name)) {
107
+ error.severity = 'warning';
108
+ }
109
+ }
110
+ else {
111
+ error.severity = 'warning';
112
+ }
105
113
  }
106
114
  else if (msg === 'unmatched closing tag') {
107
115
  const ancestor = this.closest('magic-word');
@@ -120,6 +128,14 @@ class HtmlToken extends index_1.Token {
120
128
  severity: 'warning',
121
129
  });
122
130
  }
131
+ if ((this.name === 'b' || this.name === 'strong') && this.closest('heading-title')) {
132
+ refError ??= (0, lint_1.generateForSelf)(this, { start }, '');
133
+ errors.push({
134
+ ...refError,
135
+ message: Parser.msg('bold in section header'),
136
+ severity: 'warning',
137
+ });
138
+ }
123
139
  return errors;
124
140
  }
125
141
  /**
@@ -6,7 +6,6 @@ import type { AtomToken, FileToken } from '../internal';
6
6
  export declare const galleryParams: Set<string>;
7
7
  /** 图片参数 */
8
8
  export declare class ImageParameterToken extends Token {
9
- #private;
10
9
  readonly type = "image-parameter";
11
10
  readonly name: string;
12
11
  abstract get parentNode(): FileToken | undefined;
@@ -20,4 +19,6 @@ export declare class ImageParameterToken extends Token {
20
19
  text(): string;
21
20
  /** @override */
22
21
  lint(start?: number): LintError[];
22
+ /** 获取参数值 */
23
+ getValue(): string | true;
23
24
  }
@@ -111,5 +111,13 @@ class ImageParameterToken extends index_1.Token {
111
111
  }
112
112
  return errors;
113
113
  }
114
+ /** 是否是不可变参数 */
115
+ #isVoid() {
116
+ return this.#syntax && !this.#syntax.includes('$1');
117
+ }
118
+ /** 获取参数值 */
119
+ getValue() {
120
+ return this.name === 'invalid' ? this.text() : this.#isVoid() || super.text();
121
+ }
114
122
  }
115
123
  exports.ImageParameterToken = ImageParameterToken;
@@ -12,7 +12,7 @@ import type { AstText, AttributesToken, ExtToken } from '../internal';
12
12
  export declare class ImagemapToken extends Token {
13
13
  readonly type = "ext-inner";
14
14
  readonly name: 'imagemap';
15
- readonly childNodes: (GalleryImageToken | NoincludeToken | ImagemapLinkToken | AstText)[];
15
+ readonly childNodes: readonly (GalleryImageToken | NoincludeToken | ImagemapLinkToken | AstText)[];
16
16
  abstract get firstChild(): NoincludeToken | GalleryImageToken | undefined;
17
17
  abstract get lastChild(): GalleryImageToken | NoincludeToken | ImagemapLinkToken | AstText | undefined;
18
18
  abstract get nextSibling(): undefined;
@@ -10,7 +10,7 @@ import type { AstText, ImagemapToken } from '../internal';
10
10
  */
11
11
  export declare class ImagemapLinkToken extends Token {
12
12
  readonly type = "imagemap-link";
13
- readonly childNodes: [AstText, LinkToken | ExtLinkToken, NoincludeToken];
13
+ readonly childNodes: readonly [AstText, LinkToken | ExtLinkToken, NoincludeToken];
14
14
  abstract get firstChild(): AstText;
15
15
  abstract get lastChild(): NoincludeToken;
16
16
  abstract get parentNode(): ImagemapToken | undefined;
@@ -10,7 +10,6 @@ import type { TokenTypes } from '../util/constants';
10
10
  * @classdesc `{childNodes: ...(AstText|Token)}`
11
11
  */
12
12
  export declare class Token extends AstElement {
13
- #private;
14
13
  type: TokenTypes;
15
14
  /** @class */
16
15
  constructor(wikitext?: string, config?: Parser.Config, accum?: Token[], acceptable?: Acceptable);
@@ -8,9 +8,8 @@ import type { Title } from '../../lib/title';
8
8
  * @classdesc `{childNodes: [AtomToken, ...Token]}`
9
9
  */
10
10
  export declare abstract class LinkBaseToken extends Token {
11
- #private;
12
11
  type: 'link' | 'category' | 'file' | 'gallery-image' | 'imagemap-image';
13
- readonly childNodes: [AtomToken, ...Token[]];
12
+ readonly childNodes: readonly [AtomToken, ...Token[]];
14
13
  abstract get firstChild(): AtomToken;
15
14
  abstract get lastChild(): Token;
16
15
  /**
@@ -76,7 +76,7 @@ class LinkBaseToken extends index_1.Token {
76
76
  lint(start = this.getAbsoluteIndex()) {
77
77
  const errors = super.lint(start), { childNodes: [target, linkText], type: linkType } = this, { encoded, fragment } = this.#title;
78
78
  let rect;
79
- if (linkType === 'link' && target.childNodes.some(({ type }) => type === 'template')) {
79
+ if (target.childNodes.some(({ type }) => type === 'template')) {
80
80
  rect = { start, ...this.getRootNode().posFromIndex(start) };
81
81
  errors.push((0, lint_1.generateForChild)(target, rect, 'template in an internal link target', 'warning'));
82
82
  }
@@ -84,7 +84,7 @@ class LinkBaseToken extends index_1.Token {
84
84
  rect ??= { start, ...this.getRootNode().posFromIndex(start) };
85
85
  errors.push((0, lint_1.generateForChild)(target, rect, 'unnecessary URL encoding in an internal link'));
86
86
  }
87
- if (linkType === 'link' && linkText?.childNodes.some(({ type, data }) => type === 'text' && data.includes('|'))) {
87
+ if ((linkType === 'link' || linkType === 'category') && linkText?.childNodes.some(({ type, data }) => type === 'text' && data.includes('|'))) {
88
88
  rect ??= { start, ...this.getRootNode().posFromIndex(start) };
89
89
  errors.push((0, lint_1.generateForChild)(linkText, rect, 'additional "|" in the link text', 'warning'));
90
90
  }
@@ -92,10 +92,6 @@ class LinkBaseToken extends index_1.Token {
92
92
  rect ??= { start, ...this.getRootNode().posFromIndex(start) };
93
93
  errors.push((0, lint_1.generateForChild)(target, rect, 'useless fragment'));
94
94
  }
95
- if (linkType === 'link' && this.closest('ext-link-text')) {
96
- rect ??= { start, ...this.getRootNode().posFromIndex(start) };
97
- errors.push((0, lint_1.generateForSelf)(this, rect, 'internal link in an external link'));
98
- }
99
95
  return errors;
100
96
  }
101
97
  /** @private */
@@ -8,9 +8,8 @@ import type { Token, AtomToken } from '../../internal';
8
8
  * @classdesc `{childNodes: [AtomToken, ...ImageParameterToken]}`
9
9
  */
10
10
  export declare class FileToken extends LinkBaseToken {
11
- #private;
12
11
  readonly type: 'file' | 'gallery-image' | 'imagemap-image';
13
- readonly childNodes: [AtomToken, ...ImageParameterToken[]];
12
+ readonly childNodes: readonly [AtomToken, ...ImageParameterToken[]];
14
13
  abstract get lastChild(): AtomToken | ImageParameterToken;
15
14
  /**
16
15
  * @param link 文件名
@@ -21,16 +20,26 @@ export declare class FileToken extends LinkBaseToken {
21
20
  /** @override */
22
21
  lint(start?: number): LintError[];
23
22
  /** 获取所有图片参数节点 */
24
- getAllArgs(): readonly ImageParameterToken[];
23
+ getAllArgs(): ImageParameterToken[];
25
24
  /**
26
25
  * 获取指定图片参数
27
26
  * @param key 参数名
28
27
  */
29
- getArgs(key: string): readonly ImageParameterToken[];
28
+ getArgs(key: string): ImageParameterToken[];
30
29
  /** 获取图片框架属性参数节点 */
31
- getFrameArgs(): readonly ImageParameterToken[];
30
+ getFrameArgs(): ImageParameterToken[];
32
31
  /** 获取图片水平对齐参数节点 */
33
- getHorizAlignArgs(): readonly ImageParameterToken[];
32
+ getHorizAlignArgs(): ImageParameterToken[];
34
33
  /** 获取图片垂直对齐参数节点 */
35
- getVertAlignArgs(): readonly ImageParameterToken[];
34
+ getVertAlignArgs(): ImageParameterToken[];
35
+ /**
36
+ * 获取生效的指定图片参数
37
+ * @param key 参数名
38
+ */
39
+ getArg(key: string): ImageParameterToken | undefined;
40
+ /**
41
+ * 获取生效的指定图片参数值
42
+ * @param key 参数名
43
+ */
44
+ getValue(key: string): string | true | undefined;
36
45
  }
@@ -56,6 +56,9 @@ class FileToken extends base_1.LinkBaseToken {
56
56
  const visibleNodes = childNodes.filter(node => node.text().trim());
57
57
  return visibleNodes.length !== 1 || visibleNodes[0].type !== 'arg';
58
58
  }), keys = [...new Set(args.map(({ name }) => name))].filter(key => key !== 'invalid'), frameKeys = keys.filter(key => frame.has(key)), horizAlignKeys = keys.filter(key => horizAlign.has(key)), vertAlignKeys = keys.filter(key => vertAlign.has(key));
59
+ if (this.closest('ext-link-text') && this.getValue('link')?.trim() !== '') {
60
+ errors.push((0, lint_1.generateForSelf)(this, { start }, 'internal link in an external link'));
61
+ }
59
62
  if (args.length === keys.length
60
63
  && frameKeys.length < 2
61
64
  && horizAlignKeys.length < 2
@@ -121,5 +124,20 @@ class FileToken extends base_1.LinkBaseToken {
121
124
  getVertAlignArgs() {
122
125
  return this.#getTypedArgs(vertAlign, '垂直对齐');
123
126
  }
127
+ /**
128
+ * 获取生效的指定图片参数
129
+ * @param key 参数名
130
+ */
131
+ getArg(key) {
132
+ const args = this.getArgs(key);
133
+ return args[args.length - 1];
134
+ }
135
+ /**
136
+ * 获取生效的指定图片参数值
137
+ * @param key 参数名
138
+ */
139
+ getValue(key) {
140
+ return this.getArg(key)?.getValue();
141
+ }
124
142
  }
125
143
  exports.FileToken = FileToken;
@@ -5,7 +5,6 @@ import type { Title } from '../../lib/title';
5
5
  import type { LintError } from '../../base';
6
6
  /** 图库图片 */
7
7
  export declare class GalleryImageToken extends FileToken {
8
- #private;
9
8
  type: 'gallery-image' | 'imagemap-image';
10
9
  /**
11
10
  * @param type 图片类型
@@ -13,8 +12,6 @@ export declare class GalleryImageToken extends FileToken {
13
12
  * @param text 图片参数
14
13
  */
15
14
  constructor(type: 'gallery' | 'imagemap', link: string, text?: string, config?: Parser.Config, accum?: Token[]);
16
- /** private */
17
- getTitle(): Title;
18
15
  /** @override */
19
16
  lint(start?: number): LintError[];
20
17
  }
@@ -28,7 +28,7 @@ class GalleryImageToken extends file_1.FileToken {
28
28
  this.setAttribute('bracket', false);
29
29
  this.type = `${type}-image`;
30
30
  }
31
- /** private */
31
+ /** @private */
32
32
  getTitle() {
33
33
  const imagemap = this.type === 'imagemap-image';
34
34
  return this.normalizeTitle(String(this.firstChild), imagemap ? 0 : 6, true, !imagemap);
@@ -1,4 +1,5 @@
1
1
  import { LinkBaseToken } from './base';
2
+ import type { LintError } from '../../base';
2
3
  import type { Token, AtomToken } from '../../internal';
3
4
  /**
4
5
  * 内链
@@ -6,5 +7,7 @@ import type { Token, AtomToken } from '../../internal';
6
7
  */
7
8
  export declare class LinkToken extends LinkBaseToken {
8
9
  readonly type = "link";
9
- readonly childNodes: [AtomToken] | [AtomToken, Token];
10
+ readonly childNodes: readonly [AtomToken] | readonly [AtomToken, Token];
11
+ /** @override */
12
+ lint(start?: number): LintError[];
10
13
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LinkToken = void 0;
4
+ const lint_1 = require("../../util/lint");
4
5
  const base_1 = require("./base");
5
6
  /**
6
7
  * 内链
@@ -9,5 +10,13 @@ const base_1 = require("./base");
9
10
  // @ts-expect-error not implementing all abstract methods
10
11
  class LinkToken extends base_1.LinkBaseToken {
11
12
  type = 'link';
13
+ /** @override */
14
+ lint(start = this.getAbsoluteIndex()) {
15
+ const errors = super.lint(start);
16
+ if (this.closest('ext-link-text')) {
17
+ errors.push((0, lint_1.generateForSelf)(this, { start }, 'internal link in an external link'));
18
+ }
19
+ return errors;
20
+ }
12
21
  }
13
22
  exports.LinkToken = LinkToken;
@@ -8,7 +8,7 @@ import type { AstText, CommentToken, IncludeToken, NoincludeToken, TranscludeTok
8
8
  */
9
9
  export declare class MagicLinkToken extends Token {
10
10
  type: 'free-ext-link' | 'ext-link-url';
11
- readonly childNodes: (AstText | CommentToken | IncludeToken | NoincludeToken | TranscludeToken)[];
11
+ readonly childNodes: readonly (AstText | CommentToken | IncludeToken | NoincludeToken | TranscludeToken)[];
12
12
  abstract get firstChild(): AstText | TranscludeToken;
13
13
  abstract get lastChild(): AstText | CommentToken | IncludeToken | NoincludeToken | TranscludeToken;
14
14
  /**
@@ -12,7 +12,7 @@ import type { AttributesToken } from './attributes';
12
12
  export declare class NestedToken extends Token {
13
13
  readonly type = "ext-inner";
14
14
  readonly name: string;
15
- readonly childNodes: (ExtToken | NoincludeToken | CommentToken)[];
15
+ readonly childNodes: readonly (ExtToken | NoincludeToken | CommentToken)[];
16
16
  abstract get firstChild(): ExtToken | NoincludeToken | CommentToken | undefined;
17
17
  abstract get lastChild(): ExtToken | NoincludeToken | CommentToken | undefined;
18
18
  abstract get nextSibling(): undefined;
@@ -8,7 +8,7 @@ declare type NowikiTypes = 'ext-inner' | 'comment' | 'dd' | 'double-underscore'
8
8
  */
9
9
  export declare abstract class NowikiBaseToken extends Token {
10
10
  type: NowikiTypes;
11
- readonly childNodes: [AstText];
11
+ readonly childNodes: readonly [AstText];
12
12
  abstract get firstChild(): AstText;
13
13
  abstract get lastChild(): AstText;
14
14
  /** 纯文本部分 */
@@ -2,15 +2,9 @@ import * as Parser from '../../index';
2
2
  import { NowikiBaseToken } from './base';
3
3
  import type { LintError } from '../../base';
4
4
  import type { Token } from '../index';
5
- declare const CommentToken_base: ((abstract new (...args: any[]) => {
5
+ export declare class CommentToken extends NowikiBaseToken {
6
6
  text(): string;
7
7
  lint(): Parser.LintError[];
8
- toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
9
- }) & {
10
- readonly hidden: true;
11
- }) & typeof NowikiBaseToken;
12
- /** HTML注释,不可见 */
13
- export declare class CommentToken extends CommentToken_base {
14
8
  readonly type = "comment";
15
9
  closed: boolean;
16
10
  /** @param closed 是否闭合 */
@@ -7,7 +7,7 @@ const Parser = require("../../index");
7
7
  const base_1 = require("./base");
8
8
  /** HTML注释,不可见 */
9
9
  // @ts-expect-error not implementing all abstract methods
10
- class CommentToken extends (0, hidden_1.hidden)(base_1.NowikiBaseToken) {
10
+ class CommentToken extends (0, hidden_1.hiddenToken)(base_1.NowikiBaseToken) {
11
11
  type = 'comment';
12
12
  closed;
13
13
  /** @param closed 是否闭合 */
@@ -1,20 +1,14 @@
1
1
  import * as Parser from '../../index';
2
2
  import { NowikiBaseToken } from './base';
3
3
  import type { Token } from '../index';
4
- declare const DoubleUnderscoreToken_base: ((abstract new (...args: any[]) => {
4
+ export declare class DoubleUnderscoreToken extends NowikiBaseToken {
5
5
  text(): string;
6
6
  lint(): Parser.LintError[];
7
- toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
8
- }) & {
9
- readonly hidden: true;
10
- }) & typeof NowikiBaseToken;
11
- /** 状态开关 */
12
- export declare class DoubleUnderscoreToken extends DoubleUnderscoreToken_base {
13
7
  readonly type = "double-underscore";
14
8
  /**
15
9
  * @param word 状态开关名
16
- * @param fixed 是否固定大小写
10
+ * @param sensitive 是否固定大小写
17
11
  */
18
- constructor(word: string, fixed: boolean, config?: Parser.Config, accum?: Token[]);
12
+ constructor(word: string, sensitive: boolean, config?: Parser.Config, accum?: Token[]);
19
13
  }
20
14
  export {};
@@ -6,13 +6,13 @@ const Parser = require("../../index");
6
6
  const base_1 = require("./base");
7
7
  /** 状态开关 */
8
8
  // @ts-expect-error not implementing all abstract methods
9
- class DoubleUnderscoreToken extends (0, hidden_1.hidden)(base_1.NowikiBaseToken) {
9
+ class DoubleUnderscoreToken extends (0, hidden_1.hiddenToken)(base_1.NowikiBaseToken) {
10
10
  type = 'double-underscore';
11
11
  /**
12
12
  * @param word 状态开关名
13
- * @param fixed 是否固定大小写
13
+ * @param sensitive 是否固定大小写
14
14
  */
15
- constructor(word, fixed, config = Parser.getConfig(), accum = []) {
15
+ constructor(word, sensitive, config = Parser.getConfig(), accum = []) {
16
16
  super(word, config, accum);
17
17
  }
18
18
  /** @private */
@@ -1,13 +1,7 @@
1
1
  import { NowikiBaseToken } from './base';
2
- declare const NoincludeToken_base: ((abstract new (...args: any[]) => {
2
+ export declare class NoincludeToken extends NowikiBaseToken {
3
3
  text(): string;
4
4
  lint(): import("../..").LintError[];
5
- toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
6
- }) & {
7
- readonly hidden: true;
8
- }) & typeof NowikiBaseToken;
9
- /** `<noinclude>`和`</noinclude>`,不可进行任何更改 */
10
- export declare class NoincludeToken extends NoincludeToken_base {
11
5
  readonly type = "noinclude";
12
6
  }
13
7
  export {};
@@ -5,7 +5,7 @@ const hidden_1 = require("../../mixin/hidden");
5
5
  const base_1 = require("./base");
6
6
  /** `<noinclude>`和`</noinclude>`,不可进行任何更改 */
7
7
  // @ts-expect-error not implementing all abstract methods
8
- class NoincludeToken extends (0, hidden_1.hidden)(base_1.NowikiBaseToken) {
8
+ class NoincludeToken extends (0, hidden_1.hiddenToken)(base_1.NowikiBaseToken) {
9
9
  type = 'noinclude';
10
10
  }
11
11
  exports.NoincludeToken = NoincludeToken;
@@ -18,7 +18,7 @@ class QuoteToken extends base_1.NowikiBaseToken {
18
18
  }
19
19
  /** @override */
20
20
  lint(start = this.getAbsoluteIndex()) {
21
- const { previousSibling, nextSibling } = this, message = Parser.msg('lonely "$1"', `'`), errors = [];
21
+ const { previousSibling, nextSibling, bold } = this, message = Parser.msg('lonely "$1"', `'`), errors = [];
22
22
  let refError;
23
23
  if (previousSibling?.type === 'text' && previousSibling.data.endsWith(`'`)) {
24
24
  refError = (0, lint_1.generateForSelf)(this, { start }, message);
@@ -44,6 +44,14 @@ class QuoteToken extends base_1.NowikiBaseToken {
44
44
  endCol: startCol + length,
45
45
  });
46
46
  }
47
+ if (bold && this.closest('heading-title')) {
48
+ refError ??= (0, lint_1.generateForSelf)(this, { start }, message);
49
+ errors.push({
50
+ ...refError,
51
+ message: Parser.msg('bold in section header'),
52
+ severity: 'warning',
53
+ });
54
+ }
47
55
  return errors;
48
56
  }
49
57
  }
@@ -10,7 +10,7 @@ import type { AttributesToken, ExtToken } from '../../internal';
10
10
  export declare class ParamTagToken extends Token {
11
11
  readonly type = "ext-inner";
12
12
  readonly name: string;
13
- readonly childNodes: AtomToken[];
13
+ readonly childNodes: readonly AtomToken[];
14
14
  abstract get firstChild(): AtomToken | undefined;
15
15
  abstract get lastChild(): AtomToken | undefined;
16
16
  abstract get nextSibling(): undefined;
@@ -9,7 +9,7 @@ import type { AtomToken, SyntaxToken, TranscludeToken } from '../internal';
9
9
  export declare class ParameterToken extends Token {
10
10
  readonly type = "parameter";
11
11
  readonly name: string;
12
- readonly childNodes: [Token, Token];
12
+ readonly childNodes: readonly [Token, Token];
13
13
  abstract get firstChild(): Token;
14
14
  abstract get lastChild(): Token;
15
15
  abstract get parentNode(): TranscludeToken | undefined;
package/dist/src/pre.d.ts CHANGED
@@ -9,7 +9,7 @@ import type { AstText, AttributesToken, ExtToken, ConverterToken } from '../inte
9
9
  export declare class PreToken extends Token {
10
10
  readonly type = "ext-inner";
11
11
  readonly name: 'pre';
12
- readonly childNodes: (AstText | NoincludeToken | ConverterToken)[];
12
+ readonly childNodes: readonly (AstText | NoincludeToken | ConverterToken)[];
13
13
  abstract get firstChild(): AstText | NoincludeToken | ConverterToken | undefined;
14
14
  abstract get lastChild(): AstText | NoincludeToken | ConverterToken | undefined;
15
15
  abstract get nextSibling(): undefined;
@@ -8,7 +8,7 @@ import { AttributesToken } from '../attributes';
8
8
  */
9
9
  export declare abstract class TableBaseToken extends Token {
10
10
  type: 'table' | 'tr' | 'td';
11
- readonly childNodes: [SyntaxToken, AttributesToken, ...Token[]];
11
+ readonly childNodes: readonly [SyntaxToken, AttributesToken, ...Token[]];
12
12
  abstract get firstChild(): SyntaxToken;
13
13
  abstract get lastChild(): Token;
14
14
  /**
@@ -9,7 +9,7 @@ import type { AttributesToken, TdToken, TrToken, Token } from '../../internal';
9
9
  */
10
10
  export declare class TableToken extends TrBaseToken {
11
11
  readonly type = "table";
12
- readonly childNodes: [SyntaxToken, AttributesToken, ...(TdToken | TrToken)[], SyntaxToken] | [SyntaxToken, AttributesToken, ...(TdToken | TrToken)[]];
12
+ readonly childNodes: readonly [SyntaxToken, AttributesToken, ...(TdToken | TrToken)[], SyntaxToken] | readonly [SyntaxToken, AttributesToken, ...(TdToken | TrToken)[]];
13
13
  abstract get lastChild(): AttributesToken | TdToken | TrToken | SyntaxToken;
14
14
  /** 表格是否闭合 */
15
15
  get closed(): boolean;
@@ -14,9 +14,8 @@ export type TdAttrs = Record<string, string | true> & TdSpanAttrs;
14
14
  * @classdesc `{childNodes: [SyntaxToken, AttributesToken, Token]}`
15
15
  */
16
16
  export declare class TdToken extends TableBaseToken {
17
- #private;
18
17
  readonly type = "td";
19
- readonly childNodes: [SyntaxToken, AttributesToken, Token];
18
+ readonly childNodes: readonly [SyntaxToken, AttributesToken, Token];
20
19
  abstract get parentNode(): TrToken | TableToken | undefined;
21
20
  abstract get nextSibling(): this | TrToken | SyntaxToken | undefined;
22
21
  abstract get previousSibling(): Token | undefined;
@@ -7,7 +7,7 @@ import type { Token, TdToken, TableToken, SyntaxToken, AttributesToken } from '.
7
7
  */
8
8
  export declare class TrToken extends TrBaseToken {
9
9
  readonly type = "tr";
10
- readonly childNodes: [SyntaxToken, AttributesToken, ...TdToken[]];
10
+ readonly childNodes: readonly [SyntaxToken, AttributesToken, ...TdToken[]];
11
11
  abstract get lastChild(): AttributesToken | TdToken;
12
12
  abstract get parentNode(): TableToken | undefined;
13
13
  abstract get nextSibling(): this | SyntaxToken | undefined;
@@ -10,7 +10,7 @@ import type { LintError } from '../../base';
10
10
  export declare class ExtToken extends TagPairToken {
11
11
  readonly type = "ext";
12
12
  closed: true;
13
- readonly childNodes: [AttributesToken, Token];
13
+ readonly childNodes: readonly [AttributesToken, Token];
14
14
  abstract get firstChild(): AttributesToken;
15
15
  abstract get lastChild(): Token;
16
16
  /**
@@ -2,20 +2,11 @@ import * as Parser from '../../index';
2
2
  import { TagPairToken } from './index';
3
3
  import type { LintError } from '../../base';
4
4
  import type { AstText, Token } from '../../internal';
5
- declare const IncludeToken_base: ((abstract new (...args: any[]) => {
5
+ export declare class IncludeToken extends TagPairToken {
6
6
  text(): string;
7
7
  lint(): Parser.LintError[];
8
- toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
9
- }) & {
10
- readonly hidden: true;
11
- }) & typeof TagPairToken;
12
- /**
13
- * `<includeonly>`或`<noinclude>`或`<onlyinclude>`
14
- * @classdesc `{childNodes: [AstText, AstText]}`
15
- */
16
- export declare class IncludeToken extends IncludeToken_base {
17
8
  readonly type = "include";
18
- readonly childNodes: [AstText, AstText];
9
+ readonly childNodes: readonly [AstText, AstText];
19
10
  abstract get firstChild(): AstText;
20
11
  abstract get lastChild(): AstText;
21
12
  /**
@@ -9,7 +9,7 @@ const index_1 = require("./index");
9
9
  * `<includeonly>`或`<noinclude>`或`<onlyinclude>`
10
10
  * @classdesc `{childNodes: [AstText, AstText]}`
11
11
  */
12
- class IncludeToken extends (0, hidden_1.hidden)(index_1.TagPairToken) {
12
+ class IncludeToken extends (0, hidden_1.hiddenToken)(index_1.TagPairToken) {
13
13
  type = 'include';
14
14
  /**
15
15
  * @param name 标签名
@@ -3,12 +3,11 @@ import { Token } from '../index';
3
3
  import type { AstNodes } from '../../lib/node';
4
4
  /** 成对标签 */
5
5
  export declare abstract class TagPairToken extends Token {
6
- #private;
7
6
  type: 'ext' | 'include';
8
7
  readonly name: string;
9
8
  closed: boolean;
10
9
  selfClosing: boolean;
11
- readonly childNodes: [AstNodes, AstNodes];
10
+ readonly childNodes: readonly [AstNodes, AstNodes];
12
11
  abstract get firstChild(): AstNodes;
13
12
  abstract get lastChild(): AstNodes;
14
13
  /**
@@ -9,10 +9,9 @@ import type { LintError } from '../base';
9
9
  * @classdesc `{childNodes: [AtomToken|SyntaxToken, ...AtomToken, ...ParameterToken]}`
10
10
  */
11
11
  export declare class TranscludeToken extends Token {
12
- #private;
13
12
  type: 'template' | 'magic-word';
14
13
  readonly modifier: string;
15
- readonly childNodes: [AtomToken | SyntaxToken, ...ParameterToken[]] | [SyntaxToken, AtomToken, AtomToken, ...ParameterToken[]];
14
+ readonly childNodes: readonly [AtomToken | SyntaxToken, ...ParameterToken[]] | readonly [SyntaxToken, AtomToken, AtomToken, ...ParameterToken[]];
16
15
  abstract get firstChild(): AtomToken | SyntaxToken;
17
16
  abstract get lastChild(): AtomToken | SyntaxToken | ParameterToken;
18
17
  /**
@@ -39,9 +38,9 @@ export declare class TranscludeToken extends Token {
39
38
  */
40
39
  insertAt<T extends ParameterToken>(token: T, i?: number): T;
41
40
  /** 获取所有参数 */
42
- getAllArgs(): readonly ParameterToken[];
41
+ getAllArgs(): ParameterToken[];
43
42
  /** 获取所有匿名参数 */
44
- getAnonArgs(): readonly ParameterToken[];
43
+ getAnonArgs(): ParameterToken[];
45
44
  /**
46
45
  * 获取指定参数
47
46
  * @param key 参数名
@@ -52,10 +51,10 @@ export declare class TranscludeToken extends Token {
52
51
  /**
53
52
  * 获取重名参数
54
53
  */
55
- getDuplicatedArgs(): readonly [string, ParameterToken[]][];
54
+ getDuplicatedArgs(): [string, ParameterToken[]][];
56
55
  /**
57
56
  * 对特定魔术字获取可能的取值
58
57
  * @throws `Error` 不是可接受的魔术字
59
58
  */
60
- getPossibleValues(): readonly Token[];
59
+ getPossibleValues(): Token[];
61
60
  }
package/i18n/zh-hans.json CHANGED
@@ -5,6 +5,7 @@
5
5
  "additional \"|\" in the link text": "链接文本中多余的\"|\"",
6
6
  "attributes of a closing tag": "位于闭合标签的属性",
7
7
  "bold": "粗体单引号",
8
+ "bold in section header": "段落标题中的粗体",
8
9
  "conflicting image $1 parameter": "冲突的图片$1参数",
9
10
  "containing invalid attribute": "包含无效属性",
10
11
  "content to be moved out from the table": "将被移出表格的内容",
package/i18n/zh-hant.json CHANGED
@@ -5,6 +5,7 @@
5
5
  "additional \"|\" in the link text": "連結文本中多餘的\"|\"",
6
6
  "attributes of a closing tag": "位於閉合標籤的屬性",
7
7
  "bold apostrophes": "粗體撇號",
8
+ "bold in section header": "段落標題中的粗體",
8
9
  "conflicting image $1 parameter": "衝突的圖片$1參數",
9
10
  "containing invalid attribute": "包含無效屬性",
10
11
  "content to be moved out from the table": "將被移出表格的內容",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikilint",
3
- "version": "2.3.9",
3
+ "version": "2.4.0",
4
4
  "description": "A Node.js linter for MediaWiki markup",
5
5
  "keywords": [
6
6
  "mediawiki",
@@ -31,13 +31,15 @@
31
31
  "url": "git+https://github.com/bhsd-harry/wikiparser-node.git"
32
32
  },
33
33
  "scripts": {
34
+ "declaration": "grep -rl --include='*.d.ts' '@private' dist/ | xargs gsed -i -E '/^\\s+\\/\\*\\* @private/,+1d'; grep -rl --include='*.d.ts' '#private' dist/ | xargs gsed -i '/#private/d'; node ./dist/bin/declaration.js",
34
35
  "prepublishOnly": "npm run build && rm dist/internal.js dist/base.js dist/[bmpu]*/*.d.ts",
35
- "build": "rm -rf dist/; tsc && grep -rl --include='*.d.ts' '@private' dist/ | xargs gsed -i '/@private/,+1d'",
36
+ "build": "bash build.sh",
36
37
  "diff": "git diff --ignore-all-space --color-moved",
37
38
  "lint:ts": "tsc --noEmit && eslint --cache .",
38
39
  "lint:json": "ajv -s config/.schema.json -d 'config/*.json' --strict=true --strict-required=false",
39
40
  "lint": "npm run lint:ts && npm run lint:json",
40
41
  "test": "npx wikilint test/single-page.wiki",
42
+ "test:end": "pkill -x http-server",
41
43
  "test:real": "node dist/test/real.js",
42
44
  "test:single": "node dist/test/single.js && node --prof dist/test/single.js && node --prof-process isolate-0x*-v8.log > test/processed.txt && rm isolate-0x*-v8.log"
43
45
  },