wikiparser-node 1.37.0 → 1.38.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/base.d.ts CHANGED
@@ -47,7 +47,7 @@ export declare const stages: {
47
47
  'list-range': number;
48
48
  };
49
49
  export type Stage = keyof typeof stages;
50
- 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-json", "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"];
50
+ export declare const rules: readonly ["arg-in-ext", "blank-alt", "bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "invalid-json", "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"];
51
51
  export declare namespace LintError {
52
52
  type Severity = 'error' | 'warning';
53
53
  type Rule = typeof rules[number];
@@ -155,7 +155,7 @@ export interface LanguageService {
155
155
  *
156
156
  * 销毁实例
157
157
  */
158
- destroy(): void;
158
+ destroy(): Promise<void>;
159
159
  /**
160
160
  * Provide color decorators
161
161
  *
@@ -295,6 +295,7 @@ export interface LanguageService {
295
295
  * @param user URI for wiki userpage or email address of the user / 维基用户页面地址或用户的电子邮件地址
296
296
  */
297
297
  setTargetWikipedia(wiki: string, user: string): Promise<void>;
298
+ [Symbol.dispose](): void;
298
299
  }
299
300
  export type SeverityLevel = 0 | 1 | 2 | false | 'off' | 'warning' | 'error';
300
301
  export type LintConfigValue = SeverityLevel | [SeverityLevel, Record<string, SeverityLevel>?];
package/dist/base.js CHANGED
@@ -36,6 +36,7 @@ exports.stages = (() => {
36
36
  exports.rules = (() => {
37
37
  const arr = [
38
38
  'arg-in-ext',
39
+ 'blank-alt',
39
40
  'bold-header',
40
41
  'format-leakage',
41
42
  'fostered-content',
package/dist/base.mjs CHANGED
@@ -33,6 +33,7 @@ const stages = /* @__PURE__ */ (() => {
33
33
  const rules = /* @__PURE__ */ (() => {
34
34
  const arr = [
35
35
  "arg-in-ext",
36
+ "blank-alt",
36
37
  "bold-header",
37
38
  "format-leakage",
38
39
  "fostered-content",
@@ -16,7 +16,8 @@ const diff_1 = require("../util/diff");
16
16
  * @param config.articlePath article path
17
17
  */
18
18
  const arrToObj = ({ articlePath, ...obj }) => {
19
- for (const [k, v] of Object.entries(obj)) {
19
+ for (const k in obj) {
20
+ const v = obj[k];
20
21
  if (Array.isArray(v) && v.every(x => typeof x === 'string')) {
21
22
  Object.assign(obj, { [k]: Object.fromEntries(v.map(x => [x, true])) });
22
23
  }
@@ -39,7 +40,7 @@ const filterGadget = (id) => {
39
40
  const n = Number(id);
40
41
  return n < 2300 || n > 2303; // Gadget, Gadget talk, Gadget definition, Gadget definition talk
41
42
  };
42
- const pkg = "wikiparser-node", version = "1.37.0";
43
+ const pkg = "wikiparser-node", version = "1.38.1";
43
44
  /**
44
45
  * Get the parser configuration for a Wikimedia Foundation project.
45
46
  * @param site site nickname
@@ -147,9 +148,9 @@ exports.default = async (site, url, user, force, internal) => {
147
148
  }
148
149
  else {
149
150
  const oldConfig = arrToObj(require(file)), newConfig = arrToObj(config);
150
- for (const [k, v] of Object.entries(newConfig)) {
151
+ for (const k in newConfig) {
151
152
  try {
152
- strict_1.default.deepStrictEqual(oldConfig[k], v);
153
+ strict_1.default.deepStrictEqual(oldConfig[k], newConfig[k]);
153
154
  }
154
155
  catch (e) {
155
156
  if (e instanceof strict_1.default.AssertionError) {
package/dist/index.js CHANGED
@@ -245,7 +245,7 @@ const Parser = {
245
245
  catch (e) /* c8 ignore start */ {
246
246
  if (e instanceof Error) {
247
247
  const file = path_1.default.join(__dirname, '..', 'errors', new Date().toISOString()), stage = token.getAttribute('stage');
248
- for (const k of Object.keys(config)) {
248
+ for (const k in config) {
249
249
  if (k.startsWith('regex') || config[k] instanceof Set) {
250
250
  delete config[k];
251
251
  }
@@ -356,8 +356,8 @@ const Parser = {
356
356
  args.push(arg[i]);
357
357
  delete arg[i];
358
358
  }
359
- for (const [key, value] of Object.entries(arg)) {
360
- args.push(`${key}=${value}`);
359
+ for (const key in arg) {
360
+ args.push(`${key}=${arg[key]}`);
361
361
  }
362
362
  }
363
363
  const { parserFunction } = this.getConfig(), [lcName, canonicalName] = (0, debug_1.getCanonicalName)(name, parserFunction), custom = constants_1.functionHooks.has(lcName);
@@ -490,7 +490,7 @@ const def = {
490
490
  'debugging',
491
491
  'isInterwiki',
492
492
  ]);
493
- for (const key of Object.keys(Parser)) {
493
+ for (const key in Parser) {
494
494
  if (!enumerable.has(key)) {
495
495
  def[key] = { enumerable: false };
496
496
  }
@@ -16,6 +16,7 @@ const dict = new Map([
16
16
  ]);
17
17
  const defaultLintRuleConfig = {
18
18
  'arg-in-ext': 1,
19
+ 'blank-alt': 1,
19
20
  'bold-header': [
20
21
  1,
21
22
  {
@@ -289,8 +290,8 @@ class LintRuleConfiguration {
289
290
  if (!config) {
290
291
  return;
291
292
  }
292
- for (const [key, value] of Object.entries(config)) {
293
- set(this, key, value);
293
+ for (const key in config) {
294
+ set(this, key, config[key]);
294
295
  }
295
296
  }
296
297
  /** @implements */
@@ -304,6 +305,7 @@ class LintRuleConfiguration {
304
305
  }
305
306
  /** 语法检查设置 */
306
307
  class LintConfiguration {
308
+ // @ts-expect-error lazy initialization
307
309
  #rules;
308
310
  /** @implements */
309
311
  get rules() {
@@ -331,7 +333,8 @@ class LintConfiguration {
331
333
  else {
332
334
  const { rules: ruleConfig, ...other } = (config ?? {});
333
335
  this.rules = ruleConfig;
334
- for (const [key, value] of Object.entries(other)) {
336
+ for (const key in other) {
337
+ const value = other[key];
335
338
  if (value !== undefined && Object.prototype.hasOwnProperty.call(defaultLintConfig, key)) {
336
339
  this[key] = value;
337
340
  }
package/dist/lib/lsp.d.ts CHANGED
@@ -16,7 +16,7 @@ export declare class LanguageService implements LanguageServiceBase {
16
16
  /** @param uri 任务标识 */
17
17
  constructor(uri: object);
18
18
  /** @implements */
19
- destroy(): void;
19
+ destroy(): Promise<void>;
20
20
  /**
21
21
  * Provide color decorators
22
22
  *
@@ -160,4 +160,6 @@ export declare class LanguageService implements LanguageServiceBase {
160
160
  * @since v1.18.1
161
161
  */
162
162
  setTargetWikipedia(wiki: string, user: string): Promise<void>;
163
+ /** @implements */
164
+ [Symbol.dispose](): void;
163
165
  }
package/dist/lib/lsp.js CHANGED
@@ -39,7 +39,7 @@ const refTags = new Set(['ref']), referencesTags = new Set(['ref', 'references']
39
39
  'heading',
40
40
  'magic-word-name',
41
41
  ...renameTypes,
42
- ]), plainTypes = new Set(['text', 'comment', 'noinclude', 'include']), cssSelector = ['ext', 'html', 'table'].map(s => `${s}-attr#style`).join();
42
+ ]), plainTypes = new Set(['text', 'comment', 'noinclude', 'include']), rawLilyPondCommands = new Set(['paper', 'book', 'bookpart', 'score', 'markuplist'].map(c => `\\${c}`)), cssSelector = ['ext', 'html', 'table'].map(s => `${s}-attr#style`).join();
43
43
  /^(?:http:\/\/|\/\/)/iu; // eslint-disable-line @typescript-eslint/no-unused-expressions
44
44
  const getLinkRegex = (0, common_1.getRegex)(protocol => new RegExp(`^(?:${protocol}|//)`, 'iu'));
45
45
  /**
@@ -354,13 +354,19 @@ const getSectionEnd = (section, lines, line) => {
354
354
  /* NOT FOR BROWSER ONLY END */
355
355
  /** VSCode-style language service */
356
356
  class LanguageService {
357
+ // @ts-expect-error lazy initialization
357
358
  #text;
359
+ // @ts-expect-error lazy initialization
358
360
  #text2;
359
361
  #running;
360
362
  #running2;
363
+ // @ts-expect-error lazy initialization
361
364
  #done;
365
+ // @ts-expect-error lazy initialization
362
366
  #done2;
367
+ // @ts-expect-error lazy initialization
363
368
  #config;
369
+ // @ts-expect-error lazy initialization
364
370
  #include;
365
371
  #completionConfig;
366
372
  /** @since v1.17.1 */
@@ -371,6 +377,7 @@ class LanguageService {
371
377
  data;
372
378
  /* NOT FOR BROWSER ONLY */
373
379
  /** @private */
380
+ // @ts-expect-error lazy initialization
374
381
  lilypond;
375
382
  #lilypondData;
376
383
  #mathData;
@@ -393,19 +400,12 @@ class LanguageService {
393
400
  });
394
401
  }
395
402
  /** @implements */
396
- destroy() {
403
+ async destroy() {
397
404
  Object.setPrototypeOf(this, null);
398
405
  /* NOT FOR BROWSER ONLY */
399
406
  const dir = path_1.default.join(__dirname, 'lilypond');
400
407
  if (fs_1.default.existsSync(dir)) {
401
- for (const file of fs_1.default.readdirSync(dir)) {
402
- (async () => {
403
- try {
404
- await fs_1.default.promises.unlink(path_1.default.join(dir, file));
405
- }
406
- catch { }
407
- })();
408
- }
408
+ await Promise.allSettled(fs_1.default.readdirSync(dir).map(file => fs_1.default.promises.unlink(path_1.default.join(dir, file))));
409
409
  }
410
410
  }
411
411
  /** 检查解析设置有无更新 */
@@ -632,10 +632,10 @@ class LanguageService {
632
632
  else if (!isJa) {
633
633
  name = name.slice(2, -2);
634
634
  }
635
- if (name in iAlias) {
635
+ if (Object.hasOwn(iAlias, name)) {
636
636
  name = iAlias[name];
637
637
  }
638
- else if (name in sAlias) {
638
+ else if (Object.hasOwn(sAlias, name)) {
639
639
  name = sAlias[name];
640
640
  }
641
641
  return this.#getBehaviorSwitch(name.toLowerCase());
@@ -670,10 +670,10 @@ class LanguageService {
670
670
  if (!this.data) {
671
671
  return undefined;
672
672
  }
673
- else if (name in insensitive) {
673
+ else if (Object.hasOwn(insensitive, name)) {
674
674
  name = insensitive[name];
675
675
  }
676
- else if (name in sensitive) {
676
+ else if (Object.hasOwn(sensitive, name)) {
677
677
  name = sensitive[name];
678
678
  }
679
679
  return this.#getParserFunction(name.toLowerCase());
@@ -697,6 +697,9 @@ class LanguageService {
697
697
  let type, parentNode;
698
698
  if (mt?.[8] === undefined) {
699
699
  cur = root.elementFromPoint(character, line);
700
+ if (!cur) {
701
+ return undefined;
702
+ }
700
703
  ({ type, parentNode } = cur);
701
704
  }
702
705
  if (mt?.[7] !== undefined || type === 'image-parameter') { // image parameter
@@ -790,15 +793,12 @@ class LanguageService {
790
793
  && (before[comment + 1] === '{' || !before.slice(comment).includes('\n'))) {
791
794
  return undefined;
792
795
  }
793
- const word = /\\?\b(?:\w|\b(?:->?|\.)|\bly:)+$/u.exec(curLine.slice(0, character))?.[0];
796
+ const word = /(?<!\\)\\[-a-z]+$/u.exec(curLine.slice(0, character))?.[0];
794
797
  if (word) {
795
- const data = this.#lilypondData;
796
- return word.startsWith('\\')
797
- ? getCompletion(data.filter(w => w.startsWith('\\')), 'Function', word, position)
798
- : [
799
- ...getCompletion(data.filter(w => /^[a-z]/u.test(w)), 'Variable', word, position),
800
- ...getCompletion(data.filter(w => /^[A-Z]/u.test(w)), 'Class', word, position),
801
- ];
798
+ const words = parentNode.hasAttr('raw')
799
+ ? this.#lilypondData
800
+ : this.#lilypondData.filter(c => !rawLilyPondCommands.has(c));
801
+ return getCompletion(words, 'Function', word, position);
802
802
  }
803
803
  }
804
804
  else if (type === 'ext-inner' && constants_1.mathTags.has(cur.name)) {
@@ -932,8 +932,9 @@ class LanguageService {
932
932
  let lilypondDiagnostics = [];
933
933
  if (this.lilypond) {
934
934
  const tokens = root.querySelectorAll('ext#score').filter(token => {
935
- const lang = token.getAttr('lang');
936
- return (lang === undefined || lang === 'lilypond') && token.innerText;
935
+ const lang = token.getAttr('lang'), { innerText } = token;
936
+ return (lang === undefined || lang === 'lilypond') && innerText?.trim()
937
+ && !/[#$](?!@?\s*(?:'\s*)?(?:[#"]|-?\.?\d|[a-z_][-:\w]*(?![^)\]}\s])))/iu.test(innerText);
937
938
  });
938
939
  if (tokens.length > 0) {
939
940
  const dir = path_1.default.join(__dirname, 'lilypond');
@@ -951,7 +952,7 @@ class LanguageService {
951
952
  fs_1.default.writeFileSync(file, score);
952
953
  try {
953
954
  // eslint-disable-next-line @typescript-eslint/strict-void-return
954
- await util_1.default.promisify(child_process_1.execFile)(this.lilypond, ['-s', '-o', dir, file]);
955
+ await util_1.default.promisify(child_process_1.execFile)(this.lilypond, ['-dno-print-pages', '-s', '-o', dir, file]);
955
956
  scores.set(score, []);
956
957
  }
957
958
  catch (e) {
@@ -1198,7 +1199,11 @@ class LanguageService {
1198
1199
  * @param position position / 位置
1199
1200
  */
1200
1201
  async provideDefinition(text, position) {
1201
- const root = await this.#queue(text), node = root.elementFromPoint(position.character, position.line), ext = node.is('ext') && node.name === 'ref'
1202
+ const root = await this.#queue(text), node = root.elementFromPoint(position.character, position.line);
1203
+ if (!node) {
1204
+ return undefined;
1205
+ }
1206
+ const ext = node.is('ext') && node.name === 'ref'
1202
1207
  ? node
1203
1208
  : node.closest('ext#ref'), refName = getRefTagAttr(ext, 'name');
1204
1209
  if (!refName) {
@@ -1219,7 +1224,11 @@ class LanguageService {
1219
1224
  * @param position position / 位置
1220
1225
  */
1221
1226
  async resolveRenameLocation(text, position) {
1222
- const root = await this.#queue(text), node = root.elementFromPoint(position.character, position.line), { type } = node, refName = getRefName(node), refGroup = getRefGroup(node);
1227
+ const root = await this.#queue(text), node = root.elementFromPoint(position.character, position.line);
1228
+ if (!node) {
1229
+ return undefined;
1230
+ }
1231
+ const { type } = node, refName = getRefName(node), refGroup = getRefGroup(node);
1223
1232
  return !refName && !refGroup && (!renameTypes.has(type)
1224
1233
  || type === 'parameter-key' && /^[1-9]\d*$/u.test(node.parentNode.name)
1225
1234
  || type === 'link-target' && !['link', 'redirect-target'].includes(node.parentNode.type))
@@ -1235,7 +1244,11 @@ class LanguageService {
1235
1244
  * @param newName new name / 新名称
1236
1245
  */
1237
1246
  async provideRenameEdits(text, position, newName) {
1238
- const root = await this.#queue(text), node = root.elementFromPoint(position.character, position.line), { type } = node, refName = getRefName(node), refNameGroup = refName && getRefTagAttr(node.parentNode.parentNode, 'group'), refGroup = getRefGroup(node), name = getName(node), refs = root.querySelectorAll(type).filter(token => {
1247
+ const root = await this.#queue(text), node = root.elementFromPoint(position.character, position.line);
1248
+ if (!node) {
1249
+ return undefined;
1250
+ }
1251
+ const { type } = node, refName = getRefName(node), refNameGroup = refName && getRefTagAttr(node.parentNode.parentNode, 'group'), refGroup = getRefGroup(node), name = getName(node), refs = root.querySelectorAll(type).filter(token => {
1239
1252
  const { type: t } = token.parentNode;
1240
1253
  if (type === 'link-target' && t !== 'link' && t !== 'redirect-target') {
1241
1254
  return false;
@@ -1599,6 +1612,10 @@ class LanguageService {
1599
1612
  }
1600
1613
  Object.assign(this.config, { articlePath: `${host}/wiki/` });
1601
1614
  }
1615
+ /** @implements */
1616
+ [Symbol.dispose]() {
1617
+ void this.destroy();
1618
+ }
1602
1619
  }
1603
1620
  exports.LanguageService = LanguageService;
1604
1621
  constants_1.classes['LanguageService'] = __filename;
@@ -5,8 +5,11 @@ const constants_1 = require("../util/constants");
5
5
  const diff_1 = require("../util/diff");
6
6
  /** 模拟Python的Range对象。除`step`至少为`1`外,允许负数、小数或`end < start`的情形。 */
7
7
  class Range {
8
+ // @ts-expect-error lazy initialization
8
9
  start;
10
+ // @ts-expect-error lazy initialization
9
11
  end;
12
+ // @ts-expect-error lazy initialization
10
13
  step;
11
14
  /**
12
15
  * @param str 表达式
package/dist/lib/title.js CHANGED
@@ -19,6 +19,7 @@ const resolve = (title) => {
19
19
  * MediaWiki页面标题对象
20
20
  */
21
21
  class Title {
22
+ // @ts-expect-error lazy initialization
22
23
  #main;
23
24
  #namespaces;
24
25
  #path;
@@ -178,7 +178,11 @@ const parseUrl = ({ testServer = '', articlePath = testServer }) => {
178
178
  }
179
179
  let nsVal = Number(val);
180
180
  if (Number.isNaN(nsVal)) {
181
- nsVal = nsid[val.toLowerCase().replaceAll('_', ' ')];
181
+ const key = val.toLowerCase().replaceAll('_', ' ');
182
+ if (!Object.hasOwn(nsid, key)) {
183
+ return '';
184
+ }
185
+ nsVal = nsid[key];
182
186
  }
183
187
  return namespaces[nsVal] ?? '';
184
188
  }, dictUrl = {
@@ -277,14 +281,14 @@ const parseUrl = ({ testServer = '', articlePath = testServer }) => {
277
281
  }, pad = ([arg0, arg1, arg2 = '0'], method) => arg0.includes('\0') ? arg0 : arg0[method](Number(arg1), strip(arg2)), anchorencode = (0, string_1.replaceEntities)(), special = (target, config) => {
278
282
  const title = makeTitle(target, config, -1);
279
283
  return title && title.ns === -1 ? title.prefix + title.main : 'Special:Badtitle';
280
- }, contentmodels = {
281
- js: ['JavaScript', 'javascript'],
282
- css: ['CSS'],
283
- json: ['JSON'],
284
- vue: ['Vue'],
285
- 'sanitized-css': ['Sanitized CSS'],
286
- Scribunto: ['Scribunto module'],
287
- }, contentmodel = (i, extension) => contentmodels[extension][i] ?? extension, cmp = (x, y, decode) => {
284
+ }, contentmodels = new Map([
285
+ ['js', ['JavaScript', 'javascript']],
286
+ ['css', ['CSS']],
287
+ ['json', ['JSON']],
288
+ ['vue', ['Vue']],
289
+ ['sanitized-css', ['Sanitized CSS']],
290
+ ['Scribunto', ['Scribunto module']],
291
+ ]), contentmodel = (i, extension) => contentmodels.get(extension)[i] ?? extension, cmp = (x, y, decode) => {
288
292
  const a = decode ? (0, string_1.decodeHtml)(x) : x, b = (0, string_1.decodeHtml)(y);
289
293
  return a === b || Boolean(a && b) && Number(a) === Number(b);
290
294
  }, isError = (s) => /<(?:strong|span|p|div)\s+(?:[^\s>]+\s+)*?class="\s*(?:[^"\s>]+\s+)*?error(?:\s[^">]*)?"/u.test(s), splitArg = (arg) => {
@@ -577,7 +581,7 @@ const expandMagicWord = (name, args, page = '', config = index_1.default.getConf
577
581
  }
578
582
  return main.endsWith('/doc') ? 'wikiext' : contentmodel(i, 'Scribunto');
579
583
  }
580
- return (n === 8 || n === 2 && isSubpage) && extension && extension in contentmodels
584
+ return (n === 8 || n === 2 && isSubpage) && extension && contentmodels.has(extension)
581
585
  ? contentmodel(i, extension)
582
586
  : 'wikitext';
583
587
  }
@@ -389,7 +389,9 @@ const loadLanguage = (lang) => {
389
389
  if (lang in exports.Prism.languages) {
390
390
  return lang;
391
391
  }
392
- lang = aliases[lang] ?? lang;
392
+ else if (Object.hasOwn(aliases, lang)) {
393
+ lang = aliases[lang];
394
+ }
393
395
  if (lang === 'wiki') {
394
396
  try {
395
397
  const { default: registerWiki } = require('prism-wiki');
@@ -399,13 +401,15 @@ const loadLanguage = (lang) => {
399
401
  }
400
402
  catch { }
401
403
  }
402
- const dep = dependencies[lang];
403
- if (typeof dep === 'string') {
404
- (0, exports.loadLanguage)(dep);
405
- }
406
- else if (dep) {
407
- for (const d of dep) {
408
- (0, exports.loadLanguage)(d);
404
+ if (Object.hasOwn(dependencies, lang)) {
405
+ const dep = dependencies[lang];
406
+ if (typeof dep === 'string') {
407
+ (0, exports.loadLanguage)(dep);
408
+ }
409
+ else if (dep) {
410
+ for (const d of dep) {
411
+ (0, exports.loadLanguage)(d);
412
+ }
409
413
  }
410
414
  }
411
415
  require(`prismjs/components/prism-${lang}.js`);
package/dist/src/index.js CHANGED
@@ -103,11 +103,11 @@ const lintSelectors = ['category', 'html-attr#id,ext-attr#id,table-attr#id'];
103
103
  */
104
104
  const getAcceptable = (value) => {
105
105
  const acceptable = {};
106
- for (const [k, v] of Object.entries(value)) {
106
+ for (const k in value) {
107
107
  if (k.startsWith('Stage-')) {
108
108
  for (let i = 0; i <= Number(k.slice(6)); i++) {
109
109
  for (const type of constants_1.aliases[i]) {
110
- acceptable[type] = new ranges_1.Ranges(v);
110
+ acceptable[type] = new ranges_1.Ranges(value[k]);
111
111
  }
112
112
  }
113
113
  }
@@ -115,7 +115,7 @@ const getAcceptable = (value) => {
115
115
  delete acceptable[k.slice(1)];
116
116
  }
117
117
  else {
118
- acceptable[k] = new ranges_1.Ranges(v);
118
+ acceptable[k] = new ranges_1.Ranges(value[k]);
119
119
  }
120
120
  }
121
121
  return acceptable;
@@ -78,6 +78,7 @@ let LinkBaseToken = (() => {
78
78
  }
79
79
  #bracket = (__runInitializers(this, _instanceExtraInitializers), true);
80
80
  #delimiter;
81
+ // @ts-expect-error lazy initialization
81
82
  #title;
82
83
  /* NOT FOR BROWSER END */
83
84
  /** full link / 完整链接 */
@@ -231,6 +231,18 @@ let FileToken = (() => {
231
231
  errors.push(e);
232
232
  }
233
233
  }
234
+ rule = 'blank-alt';
235
+ s = lintConfig.getSeverity(rule);
236
+ if (s) {
237
+ const alt = this.getArg('alt');
238
+ if (alt?.getValue() === '') {
239
+ const e = (0, lint_1.generateForChild)(alt, rect, rule, 'blank-alt', s);
240
+ if (computeEditInfo || fix) {
241
+ e.fix = (0, lint_1.fixByRemove)(e, -1);
242
+ }
243
+ errors.push(e);
244
+ }
245
+ }
234
246
  if (args.length === keys.length
235
247
  && frameKeys.length < 2
236
248
  && horizAlignKeys.length < 2
@@ -114,6 +114,7 @@ class NowikiToken extends base_1.NowikiBaseToken {
114
114
  }
115
115
  const e = (0, lint_1.generateForSelf)(this, { start }, rule, 'chem-required', s);
116
116
  if (result.status !== 'C') {
117
+ /** @todo native MathML supports more macros than texvcjs */
117
118
  const { message, location } = result.error, [endIndex, endLine, endCol] = updateLocation(e, location.end, n);
118
119
  [e.startIndex, e.startLine, e.startCol] = updateLocation(e, location.start, n);
119
120
  Object.assign(e, { endIndex, endLine, endCol, message });
@@ -6,6 +6,11 @@ import type { AttributesParentBase } from '../../mixin/attributesParent';
6
6
  declare type TableTypes = 'table' | 'tr' | 'td';
7
7
  export interface TableBaseToken extends AttributesParentBase {
8
8
  }
9
+ /**
10
+ * 转义表格语法
11
+ * @param syntax 表格语法节点
12
+ */
13
+ export declare const escapeTable: (syntax: SyntaxToken) => void;
9
14
  /**
10
15
  * table row that contains the newline at the beginning but not at the end
11
16
  *
@@ -37,7 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
38
  };
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.TableBaseToken = void 0;
40
+ exports.TableBaseToken = exports.escapeTable = void 0;
41
41
  const debug_1 = require("../../util/debug");
42
42
  const attributesParent_1 = require("../../mixin/attributesParent");
43
43
  const index_1 = __importDefault(require("../../index"));
@@ -58,6 +58,7 @@ const escapeTable = (syntax) => {
58
58
  syntax.safeReplaceChildren(childNodes);
59
59
  });
60
60
  };
61
+ exports.escapeTable = escapeTable;
61
62
  /**
62
63
  * table row that contains the newline at the beginning but not at the end
63
64
  *
@@ -98,7 +99,7 @@ let TableBaseToken = (() => {
98
99
  escape() {
99
100
  LSP: for (const child of this.childNodes) {
100
101
  if (child instanceof syntax_1.SyntaxToken) {
101
- escapeTable(child);
102
+ (0, exports.escapeTable)(child);
102
103
  }
103
104
  else {
104
105
  child.escape();
@@ -121,14 +122,6 @@ let TableBaseToken = (() => {
121
122
  return token;
122
123
  });
123
124
  }
124
- /** @private */
125
- setSyntax(syntax, esc) {
126
- const { firstChild } = this;
127
- firstChild.replaceChildren(syntax);
128
- if (esc) {
129
- escapeTable(firstChild);
130
- }
131
- }
132
125
  };
133
126
  return TableBaseToken = _classThis;
134
127
  })();
@@ -143,7 +143,7 @@ export declare abstract class TableToken extends TrBaseToken {
143
143
  * @param attr table attribute / 表格属性
144
144
  * @param multiRow whether to format multi-row cells / 是否对所有单元格设置,或是仅对行首单元格设置
145
145
  */
146
- formatTableRow(y: number, attr?: TdAttrs | string, multiRow?: boolean): void;
146
+ formatTableRow(y: number, attr?: TdAttrs | TdSubtypes, multiRow?: boolean): void;
147
147
  /**
148
148
  * Format the column
149
149
  *
@@ -152,7 +152,7 @@ export declare abstract class TableToken extends TrBaseToken {
152
152
  * @param attr table attribute / 表格属性
153
153
  * @param multiCol whether to format multi-column cells / 是否对所有单元格设置,或是仅对行首单元格设置
154
154
  */
155
- formatTableCol(x: number, attr?: TdAttrs | string, multiCol?: boolean): void;
155
+ formatTableCol(x: number, attr?: TdAttrs | TdSubtypes, multiCol?: boolean): void;
156
156
  /**
157
157
  * Fill the table row
158
158
  *
@@ -304,9 +304,12 @@ let TdToken = (() => {
304
304
  }
305
305
  }
306
306
  /** @private */
307
- setSyntax(syntax, esc) {
308
- const aliases = { td: '\n|', th: '\n!', caption: '\n|+' };
309
- super.setSyntax(aliases[syntax] ?? syntax, esc);
307
+ setSyntax(subtype, esc) {
308
+ const aliases = { td: '\n|', th: '\n!', caption: '\n|+' }, { firstChild } = this;
309
+ firstChild.replaceChildren(aliases[subtype]);
310
+ if (esc) {
311
+ (0, base_1.escapeTable)(firstChild);
312
+ }
310
313
  }
311
314
  /** 修复\<td\>语法 */
312
315
  #correct() {
@@ -341,8 +344,8 @@ let TdToken = (() => {
341
344
  }
342
345
  setAttr(keyOrProp, value) {
343
346
  if (typeof keyOrProp !== 'string') {
344
- for (const [key, val] of Object.entries(keyOrProp)) {
345
- this.setAttr(key, val);
347
+ for (const key in keyOrProp) {
348
+ this.setAttr(key, keyOrProp[key]);
346
349
  }
347
350
  return;
348
351
  }
@@ -134,8 +134,8 @@ let TranslateToken = (() => {
134
134
  /** @implements */
135
135
  setAttr(keyOrProp, value) {
136
136
  if (typeof keyOrProp === 'object') {
137
- for (const [key, val] of Object.entries(keyOrProp)) {
138
- this.setAttr(key, val);
137
+ for (const key in keyOrProp) {
138
+ this.setAttr(key, keyOrProp[key]);
139
139
  }
140
140
  }
141
141
  else if ((0, string_1.trimLc)(keyOrProp) === 'nowrap') {
@@ -84,6 +84,7 @@ let TranscludeToken = (() => {
84
84
  #raw = false;
85
85
  #args = new Map();
86
86
  #anonCount = 0;
87
+ // @ts-expect-error lazy initialization
87
88
  #title;
88
89
  /* NOT FOR BROWSER */
89
90
  #keys = new Set();
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extParams = exports.obsoleteAttrs = exports.extAttrs = exports.htmlAttrs = exports.commonHtmlAttrs = void 0;
4
4
  /* eslint-disable unicorn/no-unreadable-iife */
5
- const blockAttrs = new Set(['align']), citeAttrs = new Set(['cite']), citeAndAttrs = new Set(['cite', 'datetime']), widthAttrs = new Set(['width']), obsoleteTdAttrs = new Set(['axis', 'align', 'bgcolor', 'height', 'width', 'valign']), tdAttrs = new Set([...obsoleteTdAttrs, 'abbr', 'headers', 'scope', 'rowspan', 'colspan']), typeAttrs = new Set(['type']), obsoleteTableAttrs = new Set(['summary', 'align', 'bgcolor', 'cellpadding', 'cellspacing', 'frame', 'rules', 'width']), brAttrs = new Set(['clear']), trAttrs = new Set(['bgcolor', 'align', 'valign']), chemAttrs = new Set(['id', 'qid', 'forcemathmode', 'type', 'display']), syntaxHighlightAttrs = new Set([
5
+ const blockAttrs = new Set(['align']), citeAttrs = new Set(['cite']), citeAndAttrs = new Set(['cite', 'datetime']), widthAttrs = new Set(['width']), trAttrs = new Set(['bgcolor', 'align', 'valign']), obsoleteTdAttrs = new Set([...trAttrs, 'axis', 'height', 'nowrap', 'width']), tdAttrs = new Set([...obsoleteTdAttrs, 'abbr', 'headers', 'scope', 'rowspan', 'colspan']), typeAttrs = new Set(['type']), obsoleteTableAttrs = new Set(['summary', 'align', 'bgcolor', 'cellpadding', 'cellspacing', 'frame', 'rules', 'width']), brAttrs = new Set(['clear']), chemAttrs = new Set(['id', 'qid', 'forcemathmode', 'type', 'display']), syntaxHighlightAttrs = new Set([
6
6
  'enclose',
7
7
  'inline',
8
8
  'lang',