wikiparser-node 1.39.0 → 1.40.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 (54) hide show
  1. package/README.md +1 -1
  2. package/bundle/bundle-es8.min.js +30 -29
  3. package/bundle/bundle-lsp.min.js +30 -30
  4. package/bundle/bundle.min.js +19 -19
  5. package/config/.schema.json +1 -1
  6. package/config/default.json +10 -1
  7. package/config/enwiki.json +88 -87
  8. package/config/jawiki.json +162 -153
  9. package/config/minimum.json +5 -81
  10. package/config/zhwiki.json +125 -124
  11. package/data/signatures.json +1 -1
  12. package/dist/addon/attribute.js +1 -1
  13. package/dist/addon/table.js +1 -1
  14. package/dist/addon/transclude.js +3 -1
  15. package/dist/base.d.mts +6 -6
  16. package/dist/base.d.ts +6 -6
  17. package/dist/base.js +1 -0
  18. package/dist/base.mjs +1 -0
  19. package/dist/bin/config.js +1 -1
  20. package/dist/index.d.ts +5 -5
  21. package/dist/index.js +5 -1
  22. package/dist/lib/lintConfig.js +12 -0
  23. package/dist/lib/lsp.js +6 -12
  24. package/dist/lib/node.js +5 -2
  25. package/dist/lib/text.js +4 -1
  26. package/dist/lib/title.js +8 -4
  27. package/dist/mixin/elementLike.js +2 -2
  28. package/dist/parser/commentAndExt.js +2 -1
  29. package/dist/render/expand.js +3 -3
  30. package/dist/render/extension.js +15 -3
  31. package/dist/render/magicWords.js +7 -7
  32. package/dist/src/attribute.d.ts +4 -1
  33. package/dist/src/attribute.js +4 -3
  34. package/dist/src/attributes.js +27 -5
  35. package/dist/src/heading.js +8 -3
  36. package/dist/src/link/base.d.ts +1 -1
  37. package/dist/src/link/base.js +10 -6
  38. package/dist/src/link/file.js +2 -2
  39. package/dist/src/magicLink.js +20 -16
  40. package/dist/src/multiLine/gallery.d.ts +5 -3
  41. package/dist/src/multiLine/gallery.js +6 -4
  42. package/dist/src/nowiki/base.d.ts +1 -1
  43. package/dist/src/parameter.js +5 -2
  44. package/dist/src/table/tr.js +1 -1
  45. package/dist/src/tagPair/ext.js +12 -18
  46. package/dist/src/tagPair/index.d.ts +1 -1
  47. package/dist/src/transclude.d.ts +6 -1
  48. package/dist/src/transclude.js +27 -19
  49. package/dist/util/constants.js +2 -1
  50. package/extensions/dist/base.js +3 -2
  51. package/i18n/en.json +1 -0
  52. package/i18n/zh-hans.json +1 -0
  53. package/i18n/zh-hant.json +1 -0
  54. package/package.json +11 -23
@@ -214,7 +214,9 @@ let TranscludeToken = (() => {
214
214
  let i = 1;
215
215
  for (let j = 0; j < parts.length; j++) {
216
216
  const part = parts[j];
217
- if (!(templateLike || this.name === 'switch' && j > 0 || this.name === 'tag' && j > 1)) {
217
+ if (!(templateLike
218
+ || this.name === 'switch' && j > 0
219
+ || this.name === 'tag' && j > 1)) {
218
220
  part[0] = part.join('=');
219
221
  part.length = 1;
220
222
  }
@@ -257,11 +259,15 @@ let TranscludeToken = (() => {
257
259
  * 是否是模板或模块
258
260
  */
259
261
  isTemplate() {
260
- return this.type === 'template' || this.name === 'invoke';
262
+ return this.type === 'template'
263
+ || this.name === 'invoke';
261
264
  }
262
265
  /** 获取模板或模块名 */
263
266
  #getTitle() {
264
- const isTemplate = this.type === 'template', title = this.normalizeTitle((isTemplate ? '' : 'Module:') + (0, string_1.removeComment)(this.childNodes[isTemplate ? 0 : 1].text()), 10, { temporary: true, ...!isTemplate && { page: '' } });
267
+ const isTemplate = this.type === 'template', title = this.normalizeTitle((isTemplate ? '' : 'Module:')
268
+ + (0, string_1.removeComment)(this.childNodes[isTemplate ?
269
+ 0
270
+ : 1].text()), 10, { temporary: true, ...!isTemplate && { page: '' } });
265
271
  /* NOT FOR BROWSER */
266
272
  title.fragment = undefined;
267
273
  /* NOT FOR BROWSER END */
@@ -319,14 +325,15 @@ let TranscludeToken = (() => {
319
325
  }
320
326
  /** @private */
321
327
  text() {
322
- const { childNodes, length, firstChild, modifier, type, name } = this;
323
- return type === 'magic-word' && name === 'vardefine'
324
- ? ''
325
- : `{{${modifier}${type === 'magic-word'
326
- ? firstChild.text()
327
- + (length === 1 ? '' : this.#colon)
328
- + (0, string_1.text)(childNodes.slice(1), '|')
329
- : super.text('|')}}}`;
328
+ const { childNodes, length, firstChild, modifier, type, name, } = this;
329
+ if (type === 'magic-word' && name === 'vardefine') {
330
+ return '';
331
+ }
332
+ return `{{${modifier}${type === 'magic-word'
333
+ ? firstChild.text()
334
+ + (length === 1 ? '' : this.#colon)
335
+ + (0, string_1.text)(childNodes.slice(1), '|')
336
+ : super.text('|')}}}`;
330
337
  }
331
338
  /** @private */
332
339
  getAttribute(key) {
@@ -407,12 +414,10 @@ let TranscludeToken = (() => {
407
414
  /* NOT FOR BROWSER */
408
415
  const removing = typeof addedToken === 'number';
409
416
  /* NOT FOR BROWSER END */
410
- /* eslint-disable @stylistic/operator-linebreak */
411
417
  this.#anonCount +=
412
418
  removing ?
413
419
  -1 :
414
420
  1;
415
- /* eslint-enable @stylistic/operator-linebreak */
416
421
  /* NOT FOR BROWSER */
417
422
  const maxAnon = String(this.#anonCount + (removing ? 1 : 0));
418
423
  if (!removing) {
@@ -435,11 +440,11 @@ let TranscludeToken = (() => {
435
440
  for (; i < this.#anonCount; i++) {
436
441
  /* NOT FOR BROWSER END */
437
442
  const token =
438
- /* eslint-disable @stylistic/operator-linebreak, unicorn/no-negated-condition */
443
+ /* eslint-disable unicorn/no-negated-condition */
439
444
  !append ?
440
445
  args[i] :
441
446
  addedToken,
442
- /* eslint-enable @stylistic/operator-linebreak, unicorn/no-negated-condition */
447
+ /* eslint-enable unicorn/no-negated-condition */
443
448
  { name } = token, newName = String(i + 1);
444
449
  if (name !== newName || token === addedToken) {
445
450
  token.setAttribute('name', newName);
@@ -670,7 +675,9 @@ let TranscludeToken = (() => {
670
675
  * @param exact whether to match anonymosity / 是否匹配匿名性
671
676
  */
672
677
  getArg(key, exact) {
673
- return [...this.getArgs(key, exact, false)].sort((a, b) => b.compareDocumentPosition(a))[0];
678
+ return [
679
+ ...this.getArgs(key, exact, false),
680
+ ].toSorted((a, b) => b.compareDocumentPosition(a))[0];
674
681
  }
675
682
  /**
676
683
  * Remove parameters with the specified name
@@ -713,9 +720,10 @@ let TranscludeToken = (() => {
713
720
  return [...this.getArgs(key, false, false)].map(token => token.getValue());
714
721
  }
715
722
  getValue(key) {
716
- return key === undefined
717
- ? Object.fromEntries(this.getKeys().map(k => [k, this.getValue(k)]))
718
- : this.getArg(key)?.getValue();
723
+ if (key === undefined) {
724
+ return Object.fromEntries(this.getKeys().map(k => [k, this.getValue(k)]));
725
+ }
726
+ return this.getArg(key)?.getValue();
719
727
  }
720
728
  /**
721
729
  * Insert an anonymous parameter
@@ -10,8 +10,9 @@ var BuildMethod;
10
10
  BuildMethod[BuildMethod["Text"] = 1] = "Text";
11
11
  })(BuildMethod || (exports.BuildMethod = BuildMethod = {}));
12
12
  exports.enMsg = (() => {
13
+ LSP: return require(
13
14
  // eslint-disable-next-line n/no-missing-require
14
- LSP: return require('../../i18n/en.json');
15
+ '../../i18n/en.json');
15
16
  })();
16
17
  exports.galleryParams = new Set(['alt', 'link', 'lang', 'page', 'caption']);
17
18
  exports.extensions = new Set(['tiff', 'tif', 'png', 'gif', 'jpg', 'jpeg', 'webp', 'xcf', 'pdf', 'svg', 'djvu']);
@@ -1,6 +1,6 @@
1
1
  (() => {
2
2
  var _a;
3
- const version = '1.39.0', src = (_a = document.currentScript) === null || _a === void 0 ? void 0 : _a.src, file = /\/extensions\/dist\/base\.(?:min\.)?js$/u, CDN = src && file.test(src)
3
+ const version = '1.40.0', src = (_a = document.currentScript) === null || _a === void 0 ? void 0 : _a.src, file = /\/extensions\/dist\/base\.(?:min\.)?js$/u, CDN = src && file.test(src)
4
4
  ? src.replace(file, '')
5
5
  : `https://fastly.jsdelivr.net/npm/wikiparser-node@${version}`;
6
6
  const workerJS = () => {
@@ -82,7 +82,8 @@ const workerJS = () => {
82
82
  stage !== null && stage !== void 0 ? stage : Infinity,
83
83
  String(child),
84
84
  child.type === 'text'
85
- ? String(child).replace(/[&<>]/gu, p => `&${entities[p]};`)
85
+ ? String(child)
86
+ .replaceAll(/[&<>]/gu, p => `&${entities[p]};`)
86
87
  : child.print(),
87
88
  ]),
88
89
  ]);
package/i18n/en.json CHANGED
@@ -67,6 +67,7 @@
67
67
  "redirect-like": "redirect-like syntax in a list item",
68
68
  "ref-in-link": "<ref> in an internal or external link",
69
69
  "remove": null,
70
+ "required-attribute": "required $1 attribute is missing",
70
71
  "template-in-link": "template in an internal link target",
71
72
  "unbalanced-in-section-header": "unbalanced $1 in a section header",
72
73
  "unclosed": "unclosed $1",
package/i18n/zh-hans.json CHANGED
@@ -67,6 +67,7 @@
67
67
  "redirect-like": "列表项中的疑似重定向语法",
68
68
  "ref-in-link": "内部或外部链接中的<ref>",
69
69
  "remove": "移除",
70
+ "required-attribute": "缺少必需的$1属性",
70
71
  "template-in-link": "内部链接目标中的模板",
71
72
  "unbalanced-in-section-header": "章节标题中未成对的$1",
72
73
  "unclosed": "未闭合的$1",
package/i18n/zh-hant.json CHANGED
@@ -67,6 +67,7 @@
67
67
  "redirect-like": "列表項中的疑似重新導向語法",
68
68
  "ref-in-link": "內部或外部連結裡的<ref>",
69
69
  "remove": "移除",
70
+ "required-attribute": "缺少必需的$1屬性",
70
71
  "template-in-link": "內部連結目標中的模板",
71
72
  "unbalanced-in-section-header": "章節標題裡的$1未成對",
72
73
  "unclosed": "有未關閉的$1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikiparser-node",
3
- "version": "1.39.0",
3
+ "version": "1.40.0",
4
4
  "description": "A Node.js parser for MediaWiki markup with AST",
5
5
  "keywords": [
6
6
  "mediawiki",
@@ -46,13 +46,12 @@
46
46
  },
47
47
  "scripts": {
48
48
  "ls": "npm i --package-lock-only && npm ls --package-lock-only --all --omit=dev",
49
- "toc": "node dist/script/toc.js",
50
49
  "prepublishOnly": "npm run build:core",
51
50
  "build:core": "bash build.sh",
52
51
  "build:define": "bash sed.sh -i \"s/pkg = \\$PKG/pkg = $(npm pkg get name)/; s/version = \\$VERSION/version = $(npm pkg get version)/\" dist/bin/config.js",
53
52
  "build": "npm run build:core && LC_ALL=en.UTF-8 node dist/script/parserTests.js",
54
53
  "diff": "bash diff.sh",
55
- "diff:stat": "f() { git diff --stat --ignore-all-space --color=always $1 $2 -- . | grep '\\.ts'; }; f",
54
+ "diff:stat": "f() { git diff --stat -w --color=always $1 $2 -- . | grep '\\.ts'; }; f",
56
55
  "lint:ts": "tsc --noEmit && eslint --cache .",
57
56
  "lint:json": "v8r -s config/.schema.json config/*.json && v8r -s data/.schema.json data/*.json && mocha dist/test/json.js",
58
57
  "lint:md": "markdownlint-cli2 '**/*.md'",
@@ -83,50 +82,42 @@
83
82
  ]
84
83
  },
85
84
  "dependencies": {
86
- "@bhsd/cm-util": "^1.0.0",
87
- "@bhsd/common": "^2.0.0",
85
+ "@bhsd/cm-util": "^1.1.0",
86
+ "@bhsd/common": "^2.2.1",
88
87
  "@bhsd/nodejs": "^1.0.0",
89
88
  "@bhsd/stylelint-util": "^1.0.2",
90
89
  "binary-search": "^1.3.6",
91
90
  "vscode-languageserver-types": "^3.17.5"
92
91
  },
93
92
  "optionalDependencies": {
94
- "color-name": "^2.0.0",
93
+ "color-name": "~2.0.2",
95
94
  "entities": "^8.0.0",
96
95
  "mathoid-texvcjs": "^0.6.0",
97
96
  "prism-wiki": "^2.1.0",
98
97
  "prismjs": "^1.30.0",
99
- "stylelint": "^17.9.0",
98
+ "stylelint": "^17.11.0",
100
99
  "vscode-css-languageservice": "^6.3.10",
101
100
  "vscode-html-languageservice": "^5.6.2",
102
101
  "vscode-json-languageservice": "^5.7.2"
103
102
  },
104
103
  "devDependencies": {
105
- "@bhsd/code-standard": "^2.2.0",
106
- "@bhsd/test-util": "^1.1.0",
104
+ "@bhsd/code-standard": "^2.4.2",
105
+ "@bhsd/test-util": "^1.2.0",
107
106
  "@codemirror/lint": "^6.9.5",
108
107
  "@eslint/markdown": "^8.0.1",
109
- "@eslint-community/eslint-plugin-eslint-comments": "^4.7.1",
110
- "@stylistic/eslint-plugin": "^5.10.0",
111
108
  "@types/color-name": "^2.0.0",
112
109
  "@types/color-rgba": "^2.1.3",
113
110
  "@types/mocha": "^10.0.10",
114
111
  "@types/node": "^24.11.0",
115
112
  "@types/prismjs": "^1.26.6",
116
- "@typescript-eslint/eslint-plugin": "^8.59.0",
117
- "@typescript-eslint/parser": "^8.59.0",
113
+ "@typescript-eslint/eslint-plugin": "^8.59.2",
114
+ "@typescript-eslint/parser": "^8.59.2",
118
115
  "c8": "^11.0.0",
119
116
  "codejar-async": "^4.3.0",
120
117
  "color-rgba": "^3.0.0",
121
118
  "diff2html-cli": "^5.2.15",
122
119
  "esbuild": "^0.28.0",
123
- "eslint": "^10.2.1",
124
- "eslint-plugin-jsdoc": "^62.9.0",
125
- "eslint-plugin-jsonc": "^3.1.2",
126
- "eslint-plugin-n": "^17.24.0",
127
- "eslint-plugin-promise": "^7.2.1",
128
- "eslint-plugin-regexp": "^3.1.0",
129
- "eslint-plugin-unicorn": "^64.0.0",
120
+ "eslint": "^10.3.0",
130
121
  "markdownlint-cli2": "^0.22.1",
131
122
  "mocha": "^11.7.5",
132
123
  "monaco-editor": "~0.53.0",
@@ -135,9 +126,6 @@
135
126
  "v8r": "^6.0.0",
136
127
  "vscode-languageserver-textdocument": "^1.0.12"
137
128
  },
138
- "overrides": {
139
- "eslint": "^10.2.1"
140
- },
141
129
  "engines": {
142
130
  "node": "^20.19.0 || ^22.13.0 || >=24.11.0"
143
131
  }