wikilint 2.44.0 → 2.45.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 (79) hide show
  1. package/config/default.json +1 -2
  2. package/config/enwiki.json +1 -1
  3. package/config/jawiki.json +1 -1
  4. package/config/minimum.json +1 -1
  5. package/config/zhwiki.json +1 -1
  6. package/data/ext/templatedata.json +13 -5
  7. package/data/signatures.json +38 -32
  8. package/dist/base.d.mts +1 -1
  9. package/dist/base.d.ts +1 -1
  10. package/dist/bin/config.js +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/internal.d.ts +6 -1
  13. package/dist/lib/element.js +5 -5
  14. package/dist/lib/lintConfig.js +7 -0
  15. package/dist/lib/lsp.d.ts +1 -2
  16. package/dist/lib/lsp.js +18 -42
  17. package/dist/lib/node.js +2 -2
  18. package/dist/lib/text.js +2 -2
  19. package/dist/map.d.ts +4 -1
  20. package/dist/mixin/elementLike.js +29 -31
  21. package/dist/mixin/hidden.js +0 -1
  22. package/dist/mixin/paramLineParent.d.ts +26 -0
  23. package/dist/mixin/paramLineParent.js +51 -0
  24. package/dist/src/arg.js +17 -35
  25. package/dist/src/atom.d.ts +1 -1
  26. package/dist/src/atom.js +2 -0
  27. package/dist/src/attribute.js +10 -5
  28. package/dist/src/attributes.js +15 -13
  29. package/dist/src/commented.d.ts +1 -0
  30. package/dist/src/commented.js +1 -3
  31. package/dist/src/converterFlags.js +9 -5
  32. package/dist/src/converterRule.js +2 -2
  33. package/dist/src/funcTag.d.ts +23 -0
  34. package/dist/src/funcTag.js +85 -0
  35. package/dist/src/heading.js +8 -3
  36. package/dist/src/hidden.d.ts +3 -2
  37. package/dist/src/hidden.js +29 -5
  38. package/dist/src/imageParameter.js +16 -4
  39. package/dist/src/index.js +2 -2
  40. package/dist/src/link/base.js +14 -2
  41. package/dist/src/link/categorytree.d.ts +2 -0
  42. package/dist/src/link/categorytree.js +8 -5
  43. package/dist/src/link/file.js +18 -12
  44. package/dist/src/multiLine/charinsert.d.ts +16 -0
  45. package/dist/src/multiLine/charinsert.js +84 -0
  46. package/dist/src/multiLine/gallery.js +4 -4
  47. package/dist/src/multiLine/imagemap.d.ts +1 -1
  48. package/dist/src/multiLine/imagemap.js +7 -7
  49. package/dist/src/multiLine/index.d.ts +3 -0
  50. package/dist/src/multiLine/index.js +79 -18
  51. package/dist/src/multiLine/inputbox.d.ts +1 -0
  52. package/dist/src/multiLine/paramTag.d.ts +3 -0
  53. package/dist/src/multiLine/paramTag.js +60 -13
  54. package/dist/src/nested.js +7 -7
  55. package/dist/src/nowiki/quote.js +6 -5
  56. package/dist/src/paramLine.d.ts +17 -3
  57. package/dist/src/paramLine.js +123 -31
  58. package/dist/src/parameter.d.ts +6 -0
  59. package/dist/src/parameter.js +15 -1
  60. package/dist/src/singleLine/charinsertLine.d.ts +21 -0
  61. package/dist/src/singleLine/charinsertLine.js +69 -0
  62. package/dist/src/{imagemapLink.d.ts → singleLine/imagemapLink.d.ts} +8 -7
  63. package/dist/src/singleLine/imagemapLink.js +95 -0
  64. package/dist/src/singleLine/index.d.ts +10 -0
  65. package/dist/src/singleLine/index.js +16 -0
  66. package/dist/src/tag/html.js +26 -8
  67. package/dist/src/tag/index.js +18 -17
  68. package/dist/src/tagPair/ext.js +23 -2
  69. package/dist/src/tagPair/index.js +1 -10
  70. package/dist/src/transclude.js +13 -13
  71. package/dist/util/sharable.js +22 -0
  72. package/dist/util/sharable.mjs +22 -0
  73. package/dist/util/string.js +27 -2
  74. package/i18n/en.json +4 -0
  75. package/i18n/zh-hans.json +4 -0
  76. package/i18n/zh-hant.json +4 -0
  77. package/package.json +10 -18
  78. package/dist/src/imagemapLink.js +0 -34
  79. /package/dist/{util → vendor}/search.js +0 -0
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ImagemapLinkToken = void 0;
7
+ const lint_1 = require("../../util/lint");
8
+ const index_1 = __importDefault(require("../../index"));
9
+ const index_2 = require("./index");
10
+ const noinclude_1 = require("../nowiki/noinclude");
11
+ const index_3 = require("../link/index");
12
+ const extLink_1 = require("../extLink");
13
+ const shapes = new Set(['default', 'rect', 'circle', 'poly']);
14
+ /** @ignore */
15
+ const notNumeric = (s, allowNegative) => {
16
+ const n = Number(s);
17
+ return Number.isNaN(n) || n > 1e9 || !allowNegative && n < 0;
18
+ };
19
+ /**
20
+ * link inside the `<imagemap>`
21
+ *
22
+ * `<imagemap>`内的链接
23
+ * @classdesc `{childNodes: [AstText, LinkToken|ExtLinkToken, NoincludeToken]}`
24
+ */
25
+ class ImagemapLinkToken extends index_2.SingleLineToken {
26
+ get type() {
27
+ return 'imagemap-link';
28
+ }
29
+ /**
30
+ * @param pre 链接前的文本
31
+ * @param linkStuff 内外链接
32
+ * @param post 链接后的文本
33
+ */
34
+ constructor(pre, linkStuff, post, config, accum = []) {
35
+ super(undefined, config, accum);
36
+ this.append(pre, linkStuff.length === 2
37
+ // @ts-expect-error abstract class
38
+ ? new index_3.LinkToken(...linkStuff, config, accum)
39
+ // @ts-expect-error abstract class
40
+ : new extLink_1.ExtLinkToken(...linkStuff, config, accum),
41
+ // @ts-expect-error abstract class
42
+ new noinclude_1.NoincludeToken(post, config, accum));
43
+ }
44
+ /**
45
+ * 检查链接区域是否合法
46
+ * @param errors 错误列表
47
+ * @param coords 坐标字符串
48
+ * @param start 节点起始位置
49
+ * @param minCount 最少需要的坐标数量
50
+ * @param isPoly 是否为多边形
51
+ */
52
+ #lintCoords(errors, coords, start, minCount, isPoly) {
53
+ LINT: {
54
+ const parts = coords.split(/[ \t]+/u).map(s => s.trim()).filter(Boolean), { length } = parts, rule = 'invalid-imagemap', s = index_1.default.lintConfig.getSeverity(rule, 'coord');
55
+ if (s && (length < minCount || isPoly && length % 2 || parts.some(part => notNumeric(part, isPoly)))) {
56
+ errors.push((0, lint_1.generateForChild)(this.firstChild, { start }, rule, 'invalid-coord', s));
57
+ }
58
+ }
59
+ }
60
+ /** 获取链接区域图形和坐标 */
61
+ #getShape() {
62
+ const area = this.firstChild.data.trim(), i = area.search(/[ \t]/u), shape = i === -1 ? area : area.slice(0, i);
63
+ return shapes.has(shape) && [shape, area.slice(i).trim()];
64
+ }
65
+ /** @private */
66
+ lint(start = this.getAbsoluteIndex(), re) {
67
+ LINT: {
68
+ const errors = super.lint(start, re), { firstChild } = this, shapeAndCoords = this.#getShape();
69
+ if (shapeAndCoords) {
70
+ const [shape, coords] = shapeAndCoords;
71
+ switch (shape) {
72
+ case 'default':
73
+ break;
74
+ case 'rect':
75
+ this.#lintCoords(errors, coords, start, 4);
76
+ break;
77
+ case 'circle':
78
+ this.#lintCoords(errors, coords, start, 3);
79
+ break;
80
+ case 'poly':
81
+ this.#lintCoords(errors, coords, start, 1, true);
82
+ // no default
83
+ }
84
+ }
85
+ else {
86
+ const rule = 'invalid-imagemap', s = index_1.default.lintConfig.getSeverity(rule, 'shape');
87
+ if (s) {
88
+ errors.push((0, lint_1.generateForChild)(firstChild, { start }, rule, 'unrecognized-shape', s));
89
+ }
90
+ }
91
+ return errors;
92
+ }
93
+ }
94
+ }
95
+ exports.ImagemapLinkToken = ImagemapLinkToken;
@@ -0,0 +1,10 @@
1
+ import { Token } from '../index';
2
+ import type { MultiLineToken } from '../multiLine/index';
3
+ /**
4
+ * single-line token inside specific extension tags, such as `<charinsert>` and `<imagemap>`
5
+ *
6
+ * 特定扩展标签内的单行节点,如 `<charinsert>` 和 `<imagemap>`
7
+ */
8
+ export declare abstract class SingleLineToken extends Token {
9
+ abstract get parentNode(): MultiLineToken | undefined;
10
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SingleLineToken = void 0;
4
+ const index_1 = require("../index");
5
+ /**
6
+ * single-line token inside specific extension tags, such as `<charinsert>` and `<imagemap>`
7
+ *
8
+ * 特定扩展标签内的单行节点,如 `<charinsert>` 和 `<imagemap>`
9
+ */
10
+ class SingleLineToken extends index_1.Token {
11
+ /** @private */
12
+ isPlain() {
13
+ return this.type === 'plain';
14
+ }
15
+ }
16
+ exports.SingleLineToken = SingleLineToken;
@@ -112,16 +112,34 @@ let HtmlToken = (() => {
112
112
  }
113
113
  /** @private */
114
114
  text() {
115
- const { closing, selfClosing, name } = this, [, , voidTags] = this.getAttribute('config').html;
115
+ const { closing, selfClosing, name } = this, [normalTags, , voidTags] = this.getAttribute('config').html;
116
+ let slash;
116
117
  if (voidTags.includes(name)) {
117
- return closing && name !== 'br' ? '' : super.text('/');
118
+ if (closing && name !== 'br') {
119
+ return '';
120
+ }
121
+ slash = '/';
122
+ }
123
+ else {
124
+ slash = selfClosing && !closing && !normalTags.includes(name) ? '/' : '';
125
+ }
126
+ return `<${closing && !slash ? '/' : ''}${name}${closing ? '' : super.text()}${slash}>`;
127
+ }
128
+ /** 是否是无效自封闭标签 */
129
+ #lint() {
130
+ const { name, closing, selfClosing } = this, [, flexibleTags, voidTags] = this.getAttribute('config').html, isVoid = voidTags.includes(name), isFlexible = flexibleTags.includes(name), isNormal = !isVoid && !isFlexible;
131
+ if (!(closing && (selfClosing || isVoid) || selfClosing && isNormal)) {
132
+ return false;
133
+ }
134
+ else if (isVoid) {
135
+ return 2;
118
136
  }
119
- return super.text(selfClosing && !closing ? '/' : '');
137
+ return isFlexible ? 1 : 0;
120
138
  }
121
139
  /** @private */
122
140
  lint(start = this.getAbsoluteIndex(), re) {
123
141
  LINT: {
124
- const errors = super.lint(start, re), { name, parentNode, closing, selfClosing } = this, rect = new rect_1.BoundingRect(this, start), { lintConfig } = index_1.default, { computeEditInfo, fix } = lintConfig, severity = this.inTableAttrs();
142
+ const errors = super.lint(start, re), { name, parentNode, closing } = this, rect = new rect_1.BoundingRect(this, start), { lintConfig } = index_1.default, { computeEditInfo, fix } = lintConfig, severity = this.inTableAttrs();
125
143
  let rule = 'h1', s = lintConfig.getSeverity(rule, 'html');
126
144
  if (s && name === 'h1' && !closing) {
127
145
  const e = (0, lint_1.generateForSelf)(this, rect, rule, '<h1>', s);
@@ -153,9 +171,9 @@ let HtmlToken = (() => {
153
171
  }
154
172
  errors.push(e);
155
173
  }
156
- const [, flexibleTags, voidTags] = this.getAttribute('config').html, isVoid = voidTags.includes(name), isFlexible = flexibleTags.includes(name), isNormal = !isVoid && !isFlexible;
174
+ const tagType = this.#lint();
157
175
  rule = 'unmatched-tag';
158
- if (closing && (selfClosing || isVoid) || selfClosing && isNormal) {
176
+ if (tagType !== false) {
159
177
  s = lintConfig.getSeverity(rule, closing ? 'both' : 'selfClosing');
160
178
  if (s) {
161
179
  const e = (0, lint_1.generateForSelf)(this, rect, rule, closing ? 'closing-and-self-closing' : 'invalid-self-closing', s);
@@ -165,13 +183,13 @@ let HtmlToken = (() => {
165
183
  range: [e.endIndex - 2, e.endIndex - 1],
166
184
  text: '',
167
185
  };
168
- if (isFlexible) {
186
+ if (tagType === 1) {
169
187
  if (computeEditInfo) {
170
188
  e.suggestions = [open, noSelfClosing];
171
189
  }
172
190
  }
173
191
  else if (closing) {
174
- e.fix = isVoid ? open : noSelfClosing;
192
+ e.fix = tagType === 2 ? open : noSelfClosing;
175
193
  }
176
194
  else if (computeEditInfo) {
177
195
  e.suggestions = [
@@ -34,11 +34,6 @@ class TagToken extends index_1.Token {
34
34
  return `<${this.#closing ? '/' : ''}${this.#tag}${super.toString(skip)}${this.selfClosing ? '/' : ''}>`;
35
35
  }
36
36
  /** @private */
37
- text(separator = '') {
38
- const { closing } = this;
39
- return `<${closing && !separator ? '/' : ''}${this.#tag}${closing ? '' : super.text()}${separator}>`;
40
- }
41
- /** @private */
42
37
  getAttribute(key) {
43
38
  return key === 'padding'
44
39
  ? this.#tag.length + (this.#closing ? 2 : 1)
@@ -51,8 +46,9 @@ class TagToken extends index_1.Token {
51
46
  */
52
47
  findMatchingTag() {
53
48
  LINT: return (0, lint_1.cache)(this.#match, () => {
54
- const { type, name, parentNode, closing, selfClosing, } = this;
55
- let isVoid = false, isFlexible = false;
49
+ const { type, name, closing, selfClosing, } = this;
50
+ // eslint-disable-next-line prefer-const
51
+ let { parentNode } = this, isVoid = false, isFlexible = false;
56
52
  if (type === 'html') {
57
53
  const [, flexibleTags, voidTags] = this.getAttribute('config').html;
58
54
  isVoid = voidTags.includes(name);
@@ -65,27 +61,32 @@ class TagToken extends index_1.Token {
65
61
  if (!parentNode) {
66
62
  return undefined;
67
63
  }
68
- const { childNodes } = parentNode, i = childNodes.indexOf(this), siblings = closing ? childNodes.slice(0, i).reverse() : childNodes.slice(i + 1), stack = [this], { rev } = debug_1.Shadow;
69
- for (const token of siblings) {
70
- if (!token.is(type)
71
- || type === 'html' && (token.name !== name || isFlexible && token.selfClosing)) {
72
- continue;
64
+ const { childNodes } = parentNode, i = childNodes.indexOf(this), siblings = closing ? childNodes.slice(0, i) : childNodes.slice(i + 1).reverse(), stack = [this], { rev } = debug_1.Shadow;
65
+ let cur = siblings.pop();
66
+ while (cur) {
67
+ // eslint-disable-next-line no-empty, @typescript-eslint/no-unnecessary-condition
68
+ if (!cur) {
69
+ }
70
+ else if (!cur.is(type)
71
+ || type === 'html' && (cur.name !== name || isFlexible && cur.selfClosing)) {
72
+ //
73
73
  }
74
- else if (token.#closing === closing) {
74
+ else if (cur.#closing === closing) {
75
75
  /* c8 ignore next 3 */
76
76
  if (type === 'tvar') {
77
77
  return undefined;
78
78
  }
79
- stack.push(token);
79
+ stack.push(cur);
80
80
  }
81
81
  else {
82
82
  const top = stack.pop();
83
83
  if (top === this) {
84
- return token;
84
+ return cur;
85
85
  }
86
- top.#match = [rev, token];
87
- token.#match = [rev, top];
86
+ top.#match = [rev, cur];
87
+ cur.#match = [rev, top];
88
88
  }
89
+ cur = siblings.pop();
89
90
  }
90
91
  for (const token of stack) {
91
92
  token.#match = [rev, undefined];
@@ -104,8 +104,6 @@ let ExtToken = (() => {
104
104
  case 'combooption':
105
105
  case 'tab':
106
106
  case 'tabs':
107
- case 'poll':
108
- case 'seo':
109
107
  case 'langconvert':
110
108
  case 'phonos':
111
109
  switch (lcName) {
@@ -124,6 +122,12 @@ let ExtToken = (() => {
124
122
  }
125
123
  innerToken = new index_2.Token(inner, newConfig, accum);
126
124
  break;
125
+ case 'poll': {
126
+ const { MultiLineToken } = require('../multiLine/index');
127
+ // @ts-expect-error abstract class
128
+ innerToken = new MultiLineToken(inner, newConfig, accum);
129
+ break;
130
+ }
127
131
  case 'dynamicpagelist': {
128
132
  const { ParamTagToken } = require('../multiLine/paramTag');
129
133
  // @ts-expect-error abstract class
@@ -182,6 +186,18 @@ let ExtToken = (() => {
182
186
  innerToken = new CategorytreeToken(inner, undefined, newConfig, accum);
183
187
  break;
184
188
  }
189
+ case 'seo': {
190
+ const { FuncTagToken } = require('../funcTag');
191
+ // @ts-expect-error abstract class
192
+ innerToken = new FuncTagToken(inner, newConfig, accum);
193
+ break;
194
+ }
195
+ case 'charinsert': {
196
+ const { CharinsertToken } = require('../multiLine/charinsert');
197
+ // @ts-expect-error abstract class
198
+ innerToken = new CharinsertToken(inner, newConfig, accum);
199
+ break;
200
+ }
185
201
  // 更多定制扩展的代码示例:
186
202
  // ```
187
203
  // case 'extensionName': {
@@ -222,6 +238,11 @@ let ExtToken = (() => {
222
238
  }
223
239
  }
224
240
  /** @private */
241
+ text() {
242
+ const { name, firstChild, lastChild, selfClosing } = this;
243
+ return `<${name}${firstChild.text()}${selfClosing ? '/>' : `>${lastChild.text()}</${name}>`}`;
244
+ }
245
+ /** @private */
225
246
  lint(start = this.getAbsoluteIndex(), re) {
226
247
  LINT: {
227
248
  const errors = super.lint(start, re), { name } = this, { lintConfig } = index_1.default, rect = new rect_1.BoundingRect(this, start);
@@ -88,16 +88,7 @@ let TagPairToken = (() => {
88
88
  /** @private */
89
89
  toString(skip) {
90
90
  const { firstChild, lastChild, } = this, [opening, closing] = this.#tags;
91
- return this.#selfClosing
92
- ? `<${opening}${firstChild.toString(skip)}/>`
93
- : `<${opening}${firstChild.toString(skip)}>${lastChild.toString(skip)}${this.closed ? `</${closing}>` : ''}`;
94
- }
95
- /** @private */
96
- text() {
97
- const [opening, closing] = this.#tags;
98
- return this.#selfClosing
99
- ? `<${opening}${this.firstChild.text()}/>`
100
- : `<${opening}${super.text('>')}${this.closed ? `</${closing}>` : ''}`;
91
+ return `<${opening}${firstChild.toString(skip)}${this.#selfClosing ? '/>' : `>${lastChild.toString(skip)}${this.closed ? `</${closing}>` : ''}`}`;
101
92
  }
102
93
  /** @private */
103
94
  getAttribute(key) {
@@ -129,9 +129,7 @@ let TranscludeToken = (() => {
129
129
  }
130
130
  const colon = title.search(/[::]/u), fullWidth = title[colon] === ':', isFunction = colon !== -1;
131
131
  if (isFunction || parts.length === 0 && !this.#raw) {
132
- const magicWord = isFunction ? title.slice(0, colon) : title, arg = isFunction && title.slice(colon + 1), cleaned = (0, string_1.removeComment)(magicWord), name = isFunction
133
- ? cleaned.slice(cleaned.search(/\S/u)) + (fullWidth ? ':' : '')
134
- : cleaned.trim(),
132
+ const magicWord = isFunction ? title.slice(0, colon) : title, arg = isFunction && title.slice(colon + 1), cleaned = (0, string_1.removeComment)(magicWord), name = isFunction ? (0, string_1.trimStart)(cleaned) + (fullWidth ? ':' : '') : cleaned.trim(),
135
133
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
136
134
  [, isSensitive, canonicalName] = (0, debug_1.getMagicWordInfo)(name, parserFunction), isFunc = !('functionHook' in config) || functionHook.includes(canonicalName), isVar = variable.includes(canonicalName);
137
135
  if (isFunction ? canonicalName && isFunc : isVar) {
@@ -254,11 +252,11 @@ let TranscludeToken = (() => {
254
252
  if (type === 'magic-word' && name === 'vardefine') {
255
253
  return '';
256
254
  }
257
- return `{{${modifier}${type === 'magic-word'
258
- ? firstChild.text()
259
- + (length === 1 ? '' : this.#colon)
260
- + (0, string_1.text)(childNodes.slice(1), '|')
261
- : super.text('|')}}}`;
255
+ const delimiter = type === 'magic-word' ? this.#colon : '|';
256
+ return `{{${modifier.trim().toLowerCase()}${firstChild.text().trim()}${length === 1 ? '' : delimiter}${childNodes.slice(1).map(child => {
257
+ const str = child.text();
258
+ return child.type === 'parameter' ? str : str.trim();
259
+ }).join('|')}}}`;
262
260
  }
263
261
  /** @private */
264
262
  getAttribute(key) {
@@ -312,15 +310,17 @@ let TranscludeToken = (() => {
312
310
  s = lintConfig.getSeverity(rule, 'parameter');
313
311
  if (s) {
314
312
  const duplicatedArgs = this.getDuplicatedArgs()
315
- .filter(([, parameter]) => !parameter[0].querySelector('ext')), msg = 'duplicate-parameter';
313
+ .filter(([, parameter]) => !parameter[0].querySelector('ext'));
316
314
  for (const [, args] of duplicatedArgs) {
317
- Array.prototype.push.apply(errors, args.map(arg => {
318
- const e = (0, lint_1.generateForChild)(arg, rect, rule, msg, s);
315
+ const duplication = Array.from({ length: args.length });
316
+ for (let i = args.length - 1; i >= 0; i--) {
317
+ const arg = args[i], e = (0, lint_1.generateForChild)(arg, rect, rule, 'duplicate-parameter', s);
319
318
  if (computeEditInfo) {
320
319
  e.suggestions = [(0, lint_1.fixByRemove)(e, -1)];
321
320
  }
322
- return e;
323
- }));
321
+ duplication[i] = e;
322
+ }
323
+ Array.prototype.push.apply(errors, duplication);
324
324
  }
325
325
  }
326
326
  return errors;
@@ -276,4 +276,26 @@ exports.extParams = (() => ({
276
276
  'tour',
277
277
  'arialabel',
278
278
  ],
279
+ seo: [
280
+ 'hreflang_$1',
281
+ 'title',
282
+ 'title_mode',
283
+ 'title_separator',
284
+ 'keywords',
285
+ 'description',
286
+ 'canonical',
287
+ 'robots',
288
+ 'googlebot',
289
+ 'image',
290
+ 'image_width',
291
+ 'image_height',
292
+ 'image_alt',
293
+ 'type',
294
+ 'site_name',
295
+ 'locale',
296
+ 'section',
297
+ 'author',
298
+ 'published_time',
299
+ 'twitter_site',
300
+ ],
279
301
  }))();
@@ -273,6 +273,28 @@ const extParams = /* @__PURE__ */ (() => ({
273
273
  "searchfilter",
274
274
  "tour",
275
275
  "arialabel"
276
+ ],
277
+ seo: [
278
+ "hreflang_$1",
279
+ "title",
280
+ "title_mode",
281
+ "title_separator",
282
+ "keywords",
283
+ "description",
284
+ "canonical",
285
+ "robots",
286
+ "googlebot",
287
+ "image",
288
+ "image_width",
289
+ "image_height",
290
+ "image_alt",
291
+ "type",
292
+ "site_name",
293
+ "locale",
294
+ "section",
295
+ "author",
296
+ "published_time",
297
+ "twitter_site"
276
298
  ]
277
299
  }))();
278
300
  export {
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toLowerCase = exports.decodeNumber = exports.decodeHtml = exports.decodeHtmlBasic = exports.text = exports.removeComment = exports.tidy = exports.trimLc = exports.extUrlChar = exports.extUrlCharFirst = exports.zs = void 0;
3
+ exports.toLowerCase = exports.decodeNumber = exports.decodeHtml = exports.decodeHtmlBasic = exports.text = exports.removeCommentLine = exports.removeComment = exports.tidy = exports.trimStart = exports.trimLc = exports.extUrlChar = exports.extUrlCharFirst = exports.zs = void 0;
4
4
  exports.restore = restore;
5
+ const common_1 = require("@bhsd/common");
5
6
  exports.zs = String.raw ` \xA0\u1680\u2000-\u200A\u202F\u205F\u3000`;
6
7
  const commonExtUrlChar = String.raw `[^[\]<>"\0-\x1F\x7F${exports.zs}\uFFFD]`;
7
8
  exports.extUrlCharFirst = String.raw `(?:\[[\da-f:.]+\]|${commonExtUrlChar})`;
@@ -12,6 +13,12 @@ exports.extUrlChar = String.raw `(?:${commonExtUrlChar}|\0\d+[cn!~]\x7F)*`;
12
13
  */
13
14
  const trimLc = (s) => s.trim().toLowerCase();
14
15
  exports.trimLc = trimLc;
16
+ /**
17
+ * trim starting whitespaces
18
+ * @param s 字符串
19
+ */
20
+ const trimStart = (s) => s.slice((0, common_1.numLeadingSpaces)(s));
21
+ exports.trimStart = trimStart;
15
22
  function restore(s, stack, translate) {
16
23
  if (translate === 1) {
17
24
  return s.replace(/\0(\d+)g\x7F/gu, (_, p1) => restore(String(stack[p1]), stack, 2));
@@ -31,6 +38,24 @@ const factory = (regex, replace) => (str) => str.replace(regex, replace);
31
38
  exports.tidy = factory(/[\0\x7F]|\r$/gmu, '');
32
39
  /** remove half-parsed comment-like tokens */
33
40
  exports.removeComment = factory(/\0\d+[cn]\x7F/gu, '');
41
+ /**
42
+ * remove lines that only contain comments
43
+ * @param str
44
+ * @param standalone whether for a standalone document
45
+ */
46
+ const removeCommentLine = (str, standalone) => {
47
+ const lines = str.split('\n'), { length } = lines;
48
+ if (!standalone && length < 3) {
49
+ return (0, exports.removeComment)(str);
50
+ }
51
+ const offset = standalone ? 0 : 1, end = length - offset;
52
+ return (0, exports.removeComment)([
53
+ ...lines.slice(0, offset),
54
+ ...lines.slice(offset, end).filter(line => !/^(?!\s*$)(?:\s|\0\d+c\x7F)*$/u.test(line)),
55
+ ...lines.slice(end),
56
+ ].join('\n'));
57
+ };
58
+ exports.removeCommentLine = removeCommentLine;
34
59
  /**
35
60
  * extract effective wikitext
36
61
  * @param childNodes a Token's contents
@@ -52,7 +77,7 @@ const decodeHtml = (str) => {
52
77
  decodeHtmlResolved ??= (() => {
53
78
  /* NOT FOR BROWSER ONLY */
54
79
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
55
- if (typeof process === 'object' && typeof process.versions?.node === 'string') {
80
+ NPM: if (typeof process === 'object' && typeof process.versions?.node === 'string') {
56
81
  try {
57
82
  const { decodeHTMLStrict } = require('entities');
58
83
  return (s) => decodeHTMLStrict(s).replaceAll('\xA0', ' ');
package/i18n/en.json CHANGED
@@ -14,6 +14,7 @@
14
14
  "delink": null,
15
15
  "duplicate-attribute": "duplicate $1 attribute",
16
16
  "duplicate-category": "duplicate category",
17
+ "duplicate-ext-parameter": "duplicate parameter of <$1>",
17
18
  "duplicate-id": "duplicate HTML id",
18
19
  "duplicate-image-parameter": "duplicate image $1 parameter",
19
20
  "duplicate-parameter": "duplicate template parameter",
@@ -39,6 +40,7 @@
39
40
  "invalid-category": "invalid category name",
40
41
  "invalid-content": "invalid content in <$1>",
41
42
  "invalid-conversion-flag": "invalid conversion flag",
43
+ "invalid-coord": "invalid coordinates",
42
44
  "invalid-gallery": "invalid gallery image",
43
45
  "invalid-gallery-link": "invalid link in gallery image",
44
46
  "invalid-image-parameter": "invalid image parameter",
@@ -46,6 +48,7 @@
46
48
  "invalid-isbn": "invalid ISBN",
47
49
  "invalid-parameter": "invalid parameter of <$1>",
48
50
  "invalid-self-closing": "invalid self-closing tag",
51
+ "invalid-space": "invalid whitespace in <$1>",
49
52
  "invalid-thumb": "invalid thumbnail filename",
50
53
  "invalid-url": "invalid URL",
51
54
  "invisible-triple-braces": "invisible content inside triple braces",
@@ -86,6 +89,7 @@
86
89
  "unexpected-argument": "unexpected template argument",
87
90
  "unmatched-closing": "unmatched closing tag",
88
91
  "unnecessary-encoding": "unnecessary percent-encoding in an internal link",
92
+ "unrecognized-shape": "unrecognized shape, which must be one of \"default\", \"rect\", \"circle\", or \"poly\"",
89
93
  "uppercase": null,
90
94
  "useless-attribute": "useless attribute",
91
95
  "useless-fragment": "useless fragment",
package/i18n/zh-hans.json CHANGED
@@ -14,6 +14,7 @@
14
14
  "delink": "移除链接",
15
15
  "duplicate-attribute": "重复的$1属性",
16
16
  "duplicate-category": "重复的分类",
17
+ "duplicate-ext-parameter": "重复的<$1>参数",
17
18
  "duplicate-id": "重复的HTML id属性",
18
19
  "duplicate-image-parameter": "重复的图像$1参数",
19
20
  "duplicate-parameter": "重复的模板参数",
@@ -39,6 +40,7 @@
39
40
  "invalid-category": "无效的分类名",
40
41
  "invalid-content": "<$1>中的无效内容",
41
42
  "invalid-conversion-flag": "无效的转换旗标",
43
+ "invalid-coord": "不正确的坐标",
42
44
  "invalid-gallery": "无效的图库图像",
43
45
  "invalid-gallery-link": "图库图像中的无效链接",
44
46
  "invalid-image-parameter": "无效的图像参数",
@@ -46,6 +48,7 @@
46
48
  "invalid-isbn": "无效的ISBN",
47
49
  "invalid-parameter": "无效的<$1>参数",
48
50
  "invalid-self-closing": "无效自封闭标签",
51
+ "invalid-space": "<$1>中的无效空白字符",
49
52
  "invalid-thumb": "无效的缩略图文件名",
50
53
  "invalid-url": "无效的URL",
51
54
  "invisible-triple-braces": "三重括号内的不可见内容",
@@ -86,6 +89,7 @@
86
89
  "unexpected-argument": "未预期的模板参数",
87
90
  "unmatched-closing": "未匹配的结束标签",
88
91
  "unnecessary-encoding": "内部链接中不必要的百分号编码",
92
+ "unrecognized-shape": "未能认出的形状,必须是这些字面量:\"default\"、\"rect\"、\"circle\"、\"poly\"",
89
93
  "uppercase": "大写",
90
94
  "useless-attribute": "无用的属性",
91
95
  "useless-fragment": "无用的片段",
package/i18n/zh-hant.json CHANGED
@@ -14,6 +14,7 @@
14
14
  "delink": "解除連結",
15
15
  "duplicate-attribute": "重複的$1屬性",
16
16
  "duplicate-category": "重複的分類",
17
+ "duplicate-ext-parameter": "重複的<$1>參數",
17
18
  "duplicate-id": "重複的HTML id屬性",
18
19
  "duplicate-image-parameter": "重複的圖片$1參數",
19
20
  "duplicate-parameter": "重複的模板參數",
@@ -39,6 +40,7 @@
39
40
  "invalid-category": "無效的分類名",
40
41
  "invalid-content": "<$1>有無效內容",
41
42
  "invalid-conversion-flag": "無效的轉換旗標",
43
+ "invalid-coord": "不正確的座標",
42
44
  "invalid-gallery": "無效的圖庫圖片",
43
45
  "invalid-gallery-link": "圖庫圖片裡有無效連結",
44
46
  "invalid-image-parameter": "無效的圖片參數",
@@ -46,6 +48,7 @@
46
48
  "invalid-isbn": "無效的ISBN",
47
49
  "invalid-parameter": "無效的<$1>參數",
48
50
  "invalid-self-closing": "無效自封閉標籤",
51
+ "invalid-space": "<$1>裡有無效空白字元",
49
52
  "invalid-thumb": "無效的縮略圖檔名",
50
53
  "invalid-url": "無效的URL",
51
54
  "invisible-triple-braces": "三重括號內有不可見內容",
@@ -86,6 +89,7 @@
86
89
  "unexpected-argument": "未預期的模板參數",
87
90
  "unmatched-closing": "未匹配的結束標籤",
88
91
  "unnecessary-encoding": "內部連結中有不需要的百分比編碼",
92
+ "unrecognized-shape": "無法辨識的形狀,必須使用下列其中一組字:\"default\"、\"rect\"、\"circle\"或\"poly\"",
89
93
  "uppercase": "大寫",
90
94
  "useless-attribute": "無用屬性",
91
95
  "useless-fragment": "無用的片段內容",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikilint",
3
- "version": "2.44.0",
3
+ "version": "2.45.0",
4
4
  "description": "A Node.js linter for MediaWiki markup",
5
5
  "keywords": [
6
6
  "mediawiki",
@@ -74,7 +74,6 @@
74
74
  ]
75
75
  },
76
76
  "peerDependencies": {
77
- "color-name": ">=2.0.0",
78
77
  "mathoid-texvcjs": ">=0.4.0",
79
78
  "stylelint": ">=16.0.0",
80
79
  "vscode-css-languageservice": ">=3.0.0",
@@ -82,9 +81,6 @@
82
81
  "vscode-json-languageservice": ">=3.2.0"
83
82
  },
84
83
  "peerDependenciesMeta": {
85
- "color-name": {
86
- "optional": true
87
- },
88
84
  "mathoid-texvcjs": {
89
85
  "optional": true
90
86
  },
@@ -103,27 +99,23 @@
103
99
  },
104
100
  "dependencies": {
105
101
  "@bhsd/cm-util": "^2.2.0",
106
- "@bhsd/common": "^2.2.1",
102
+ "@bhsd/common": "^3.0.0",
107
103
  "@bhsd/stylelint-util": "^1.1.0",
108
104
  "entities": "^8.0.0",
109
- "vscode-languageserver-types": "^3.17.5"
105
+ "vscode-languageserver-types": "^3.18.0"
110
106
  },
111
107
  "devDependencies": {
112
- "@bhsd/code-standard": "^2.6.2",
113
- "@bhsd/nodejs": "^1.0.1",
114
- "@bhsd/test-util": "^1.5.0",
115
- "@types/color-name": "^2.0.0",
116
- "@types/color-rgba": "^2.1.3",
108
+ "@bhsd/code-standard": "^3.1.0",
109
+ "@bhsd/nodejs": "^1.1.0",
110
+ "@bhsd/test-util": "^2.0.0",
117
111
  "c8": "^11.0.0",
118
- "color-name": "~2.0.2",
119
- "color-rgba": "^3.0.0",
120
112
  "diff2html-cli": "^5.2.15",
121
- "esbuild": "^0.28.0",
122
- "eslint": "^10.4.1",
123
- "markdownlint-cli2": "^0.22.1",
113
+ "esbuild": "^0.28.1",
114
+ "eslint": "^10.6.0",
115
+ "markdownlint-cli2": "^0.23.0",
124
116
  "mathoid-texvcjs": "^0.6.0",
125
117
  "mocha": "^11.7.6",
126
- "stylelint": "^17.13.0",
118
+ "stylelint": "^17.14.0",
127
119
  "typescript": "^6.0.3",
128
120
  "v8r": "^6.1.0",
129
121
  "vscode-css-languageservice": "^6.3.10",