wikilint 2.18.4 → 2.20.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 (85) hide show
  1. package/config/default.json +49 -3
  2. package/config/minimum.json +5 -1
  3. package/data/ext/math.json +660 -0
  4. package/dist/base.d.mts +4 -3
  5. package/dist/base.d.ts +4 -3
  6. package/dist/bin/cli.js +19 -6
  7. package/dist/bin/config.js +26 -8
  8. package/dist/index.d.ts +2 -2
  9. package/dist/index.js +10 -1
  10. package/dist/internal.d.ts +2 -0
  11. package/dist/lib/document.d.ts +5 -0
  12. package/dist/lib/document.js +31 -1
  13. package/dist/lib/element.js +15 -4
  14. package/dist/lib/lsp.js +103 -41
  15. package/dist/lib/node.js +0 -7
  16. package/dist/lib/text.js +3 -7
  17. package/dist/lib/title.js +1 -6
  18. package/dist/mixin/attributesParent.js +1 -1
  19. package/dist/mixin/gapped.d.ts +4 -0
  20. package/dist/mixin/gapped.js +20 -0
  21. package/dist/mixin/hidden.js +1 -1
  22. package/dist/mixin/multiLine.d.ts +4 -0
  23. package/dist/mixin/multiLine.js +26 -0
  24. package/dist/mixin/padded.d.ts +5 -0
  25. package/dist/mixin/padded.js +20 -0
  26. package/dist/parser/braces.js +9 -13
  27. package/dist/parser/commentAndExt.js +18 -2
  28. package/dist/parser/magicLinks.js +1 -1
  29. package/dist/parser/selector.js +5 -2
  30. package/dist/src/arg.js +131 -84
  31. package/dist/src/attribute.js +4 -4
  32. package/dist/src/attributes.js +2 -2
  33. package/dist/src/commented.d.ts +19 -0
  34. package/dist/src/commented.js +41 -0
  35. package/dist/src/converter.js +90 -43
  36. package/dist/src/converterFlags.js +113 -66
  37. package/dist/src/converterRule.d.ts +1 -1
  38. package/dist/src/extLink.d.ts +2 -3
  39. package/dist/src/extLink.js +97 -54
  40. package/dist/src/gallery.d.ts +3 -4
  41. package/dist/src/gallery.js +114 -72
  42. package/dist/src/heading.js +10 -10
  43. package/dist/src/imageParameter.d.ts +1 -1
  44. package/dist/src/imageParameter.js +11 -8
  45. package/dist/src/imagemap.d.ts +1 -1
  46. package/dist/src/imagemap.js +126 -86
  47. package/dist/src/imagemapLink.d.ts +1 -1
  48. package/dist/src/index.js +18 -15
  49. package/dist/src/link/base.d.ts +2 -3
  50. package/dist/src/link/base.js +149 -105
  51. package/dist/src/link/file.d.ts +2 -3
  52. package/dist/src/link/file.js +2 -2
  53. package/dist/src/link/galleryImage.d.ts +2 -3
  54. package/dist/src/link/galleryImage.js +89 -47
  55. package/dist/src/nested.d.ts +1 -1
  56. package/dist/src/nowiki/comment.js +2 -5
  57. package/dist/src/nowiki/doubleUnderscore.js +2 -5
  58. package/dist/src/nowiki/index.d.ts +1 -1
  59. package/dist/src/nowiki/index.js +2 -1
  60. package/dist/src/onlyinclude.js +63 -15
  61. package/dist/src/paramTag/index.d.ts +1 -1
  62. package/dist/src/paramTag/index.js +89 -47
  63. package/dist/src/paramTag/inputbox.js +9 -4
  64. package/dist/src/parameter.d.ts +3 -4
  65. package/dist/src/parameter.js +4 -8
  66. package/dist/src/pre.d.ts +3 -4
  67. package/dist/src/pre.js +5 -9
  68. package/dist/src/syntax.d.ts +1 -1
  69. package/dist/src/table/base.d.ts +2 -2
  70. package/dist/src/table/base.js +3 -7
  71. package/dist/src/table/index.js +1 -1
  72. package/dist/src/table/td.d.ts +2 -3
  73. package/dist/src/table/td.js +3 -7
  74. package/dist/src/table/tr.d.ts +1 -1
  75. package/dist/src/tagPair/ext.js +38 -33
  76. package/dist/src/tagPair/index.d.ts +1 -1
  77. package/dist/src/tagPair/index.js +94 -47
  78. package/dist/src/tagPair/translate.d.ts +22 -0
  79. package/dist/src/tagPair/translate.js +48 -0
  80. package/dist/src/transclude.js +378 -332
  81. package/dist/util/lint.js +17 -30
  82. package/dist/util/sharable.js +29 -1
  83. package/dist/util/sharable.mjs +31 -3
  84. package/dist/util/string.js +14 -1
  85. package/package.json +8 -6
package/dist/util/lint.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.htmlData = exports.cache = exports.generateForSelf = exports.generateForChild = exports.getEndPos = void 0;
6
+ exports.provideValues = exports.cache = exports.generateForSelf = exports.generateForChild = exports.getEndPos = void 0;
7
7
  const debug_1 = require("./debug");
8
8
  const rect_1 = require("../lib/rect");
9
9
  const index_1 = __importDefault(require("../index"));
@@ -61,34 +61,21 @@ const cache = (store, compute, update) => {
61
61
  return result;
62
62
  };
63
63
  exports.cache = cache;
64
- exports.htmlData = (() => {
65
- try {
66
- return require('vscode-html-languageservice')
67
- .getDefaultHTMLDataProvider();
64
+ /**
65
+ * 获取HTML属性值可选列表
66
+ * @param tag 标签名
67
+ * @param attribute 属性名
68
+ */
69
+ const provideValues = (tag, attribute) => {
70
+ if (tag === 'ol' && attribute === 'type') {
71
+ return ['1', 'a', 'A', 'i', 'I'];
68
72
  }
69
- catch {
70
- /**
71
- * 获取HTML属性值可选列表
72
- * @param tag 标签名
73
- * @param attribute 属性名
74
- */
75
- const provideValues = (tag, attribute) => {
76
- if (tag === 'ol' && attribute === 'type') {
77
- return ['1', 'a', 'A', 'i', 'I'];
78
- }
79
- else if (tag === 'th' && attribute === 'scope') {
80
- return ['row', 'col', 'rowgroup', 'colgroup'];
81
- }
82
- else if (attribute === 'dir') {
83
- return ['ltr', 'rtl', 'auto'];
84
- }
85
- return attribute === 'aria-hidden' ? ['true', 'false'] : [];
86
- };
87
- return {
88
- /** @implements */
89
- provideValues(tag, attribute) {
90
- return provideValues(tag, attribute).map(value => ({ name: value }));
91
- },
92
- };
73
+ else if (tag === 'th' && attribute === 'scope') {
74
+ return ['row', 'col', 'rowgroup', 'colgroup'];
93
75
  }
94
- })();
76
+ else if (attribute === 'dir') {
77
+ return ['ltr', 'rtl', 'auto'];
78
+ }
79
+ return attribute === 'aria-hidden' ? ['true', 'false'] : [];
80
+ };
81
+ exports.provideValues = provideValues;
@@ -2,7 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  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']), empty = new Set();
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(['qid', 'forcemathmode', 'type', 'display']), syntaxHighlightAttrs = new Set([
6
+ 'enclose',
7
+ 'inline',
8
+ 'lang',
9
+ 'line',
10
+ 'linelinks',
11
+ 'style',
12
+ 'class',
13
+ 'id',
14
+ 'dir',
15
+ 'copy',
16
+ 'highlight',
17
+ 'start',
18
+ ]), empty = new Set();
6
19
  exports.commonHtmlAttrs = new Set([
7
20
  'id',
8
21
  'class',
@@ -63,6 +76,9 @@ exports.commonHtmlAttrs = new Set([
63
76
  poem: blockAttrs,
64
77
  categorytree: blockAttrs,
65
78
  combooption: blockAttrs,
79
+ math: empty,
80
+ chem: empty,
81
+ ce: empty,
66
82
  }))(), exports.extAttrs = (() => ({
67
83
  gallery: new Set(['mode', 'showfilename', 'caption', 'perrow', 'widths', 'heights', 'showthumbnails']),
68
84
  poem: new Set(['compact']),
@@ -142,6 +158,18 @@ exports.commonHtmlAttrs = new Set([
142
158
  ]),
143
159
  tabs: new Set(['plain', 'class', 'container', 'id', 'title', 'style']),
144
160
  combobox: new Set(['placeholder', 'value', 'id', 'class', 'text', 'dropdown', 'style']),
161
+ math: new Set([...chemAttrs, 'chem']),
162
+ chem: chemAttrs,
163
+ ce: chemAttrs,
164
+ hiero: empty,
165
+ phonos: new Set(['ipa', 'class', 'text', 'lang', 'wikibase', 'file']),
166
+ section: new Set(['begin', 'end']),
167
+ source: syntaxHighlightAttrs,
168
+ syntaxhighlight: syntaxHighlightAttrs,
169
+ templatedata: empty,
170
+ timeline: new Set(['method', 'font']),
171
+ quiz: new Set(['display', 'shuffleanswers', 'points', 'shuffle', 'case']),
172
+ languages: empty,
145
173
  }))(), exports.obsoleteAttrs = (() => ({
146
174
  table: obsoleteTableAttrs,
147
175
  td: new Set([...obsoleteTdAttrs, 'scope']),
@@ -1,6 +1,19 @@
1
1
  const blockAttrs = /* @__PURE__ */ new Set(["align"]), citeAttrs = /* @__PURE__ */ new Set(["cite"]), citeAndAttrs = /* @__PURE__ */ new Set(["cite", "datetime"]), widthAttrs = /* @__PURE__ */ new Set(["width"]), obsoleteTdAttrs = /* @__PURE__ */ new Set(["axis", "align", "bgcolor", "height", "width", "valign"]), tdAttrs = /* @__PURE__ */ new Set([...obsoleteTdAttrs, "abbr", "headers", "scope", "rowspan", "colspan"]), typeAttrs = /* @__PURE__ */ new Set(["type"]), obsoleteTableAttrs = /* @__PURE__ */ new Set(
2
2
  ["summary", "align", "bgcolor", "cellpadding", "cellspacing", "frame", "rules", "width"]
3
- ), brAttrs = /* @__PURE__ */ new Set(["clear"]), trAttrs = /* @__PURE__ */ new Set(["bgcolor", "align", "valign"]), empty = /* @__PURE__ */ new Set();
3
+ ), brAttrs = /* @__PURE__ */ new Set(["clear"]), trAttrs = /* @__PURE__ */ new Set(["bgcolor", "align", "valign"]), chemAttrs = /* @__PURE__ */ new Set(["qid", "forcemathmode", "type", "display"]), syntaxHighlightAttrs = /* @__PURE__ */ new Set([
4
+ "enclose",
5
+ "inline",
6
+ "lang",
7
+ "line",
8
+ "linelinks",
9
+ "style",
10
+ "class",
11
+ "id",
12
+ "dir",
13
+ "copy",
14
+ "highlight",
15
+ "start"
16
+ ]), empty = /* @__PURE__ */ new Set();
4
17
  const commonHtmlAttrs = /* @__PURE__ */ new Set([
5
18
  "id",
6
19
  "class",
@@ -60,7 +73,10 @@ const commonHtmlAttrs = /* @__PURE__ */ new Set([
60
73
  gallery: typeAttrs,
61
74
  poem: blockAttrs,
62
75
  categorytree: blockAttrs,
63
- combooption: blockAttrs
76
+ combooption: blockAttrs,
77
+ math: empty,
78
+ chem: empty,
79
+ ce: empty
64
80
  }))(), extAttrs = /* @__PURE__ */ (() => ({
65
81
  gallery: /* @__PURE__ */ new Set(["mode", "showfilename", "caption", "perrow", "widths", "heights", "showthumbnails"]),
66
82
  poem: /* @__PURE__ */ new Set(["compact"]),
@@ -139,7 +155,19 @@ const commonHtmlAttrs = /* @__PURE__ */ new Set([
139
155
  "title"
140
156
  ]),
141
157
  tabs: /* @__PURE__ */ new Set(["plain", "class", "container", "id", "title", "style"]),
142
- combobox: /* @__PURE__ */ new Set(["placeholder", "value", "id", "class", "text", "dropdown", "style"])
158
+ combobox: /* @__PURE__ */ new Set(["placeholder", "value", "id", "class", "text", "dropdown", "style"]),
159
+ math: /* @__PURE__ */ new Set([...chemAttrs, "chem"]),
160
+ chem: chemAttrs,
161
+ ce: chemAttrs,
162
+ hiero: empty,
163
+ phonos: /* @__PURE__ */ new Set(["ipa", "class", "text", "lang", "wikibase", "file"]),
164
+ section: /* @__PURE__ */ new Set(["begin", "end"]),
165
+ source: syntaxHighlightAttrs,
166
+ syntaxhighlight: syntaxHighlightAttrs,
167
+ templatedata: empty,
168
+ timeline: /* @__PURE__ */ new Set(["method", "font"]),
169
+ quiz: /* @__PURE__ */ new Set(["display", "shuffleanswers", "points", "shuffle", "case"]),
170
+ languages: empty
143
171
  }))(), obsoleteAttrs = /* @__PURE__ */ (() => ({
144
172
  table: obsoleteTableAttrs,
145
173
  td: /* @__PURE__ */ new Set([...obsoleteTdAttrs, "scope"]),
@@ -1,12 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noWrap = exports.decodeNumber = exports.decodeHtml = exports.decodeHtmlBasic = exports.text = exports.escapeRegExp = exports.removeComment = exports.tidy = exports.extUrlChar = exports.extUrlCharFirst = exports.zs = exports.rawurldecode = void 0;
3
+ exports.noWrap = exports.decodeNumber = exports.decodeHtml = exports.decodeHtmlBasic = exports.text = exports.escapeRegExp = exports.removeComment = exports.tidy = exports.restore = exports.trimLc = exports.extUrlChar = exports.extUrlCharFirst = exports.zs = exports.rawurldecode = void 0;
4
4
  var common_1 = require("@bhsd/common");
5
5
  Object.defineProperty(exports, "rawurldecode", { enumerable: true, get: function () { return common_1.rawurldecode; } });
6
6
  exports.zs = String.raw ` \xA0\u1680\u2000-\u200A\u202F\u205F\u3000`;
7
7
  const commonExtUrlChar = String.raw `[^[\]<>"\0-\x1F\x7F${exports.zs}\uFFFD]`;
8
8
  exports.extUrlCharFirst = String.raw `(?:\[[\da-f:.]+\]|${commonExtUrlChar})`;
9
9
  exports.extUrlChar = String.raw `(?:${commonExtUrlChar}|\0\d+[cn!~]\x7F)*`;
10
+ /**
11
+ * trim and toLowerCase
12
+ * @param s 字符串
13
+ */
14
+ const trimLc = (s) => s.trim().toLowerCase();
15
+ exports.trimLc = trimLc;
16
+ /**
17
+ * 恢复原始字符串
18
+ * @param s 更改后的字符串
19
+ * @param stack 原始字符串片段
20
+ */
21
+ const restore = (s, stack) => s.replace(/\0(\d+)\x7F/gu, (_, p1) => stack[p1]);
22
+ exports.restore = restore;
10
23
  /**
11
24
  * 生成正则替换函数
12
25
  * @param regex 正则表达式
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikilint",
3
- "version": "2.18.4",
3
+ "version": "2.20.0",
4
4
  "description": "A Node.js linter for MediaWiki markup",
5
5
  "keywords": [
6
6
  "mediawiki",
@@ -17,6 +17,7 @@
17
17
  "files": [
18
18
  "/errors/README",
19
19
  "/config/",
20
+ "!/config/mediawikiwiki.json",
20
21
  "/data/",
21
22
  "/i18n/",
22
23
  "/coverage/badge.svg",
@@ -65,13 +66,14 @@
65
66
  ]
66
67
  },
67
68
  "dependencies": {
68
- "@bhsd/common": "^0.9.1",
69
+ "@bhsd/common": "^0.9.3",
69
70
  "vscode-languageserver-types": "^3.17.5"
70
71
  },
71
72
  "optionalDependencies": {
72
73
  "chalk": "^4.1.2",
73
74
  "color-name": "^2.0.0",
74
75
  "entities": "^6.0.0",
76
+ "mathjax": "^3.2.2",
75
77
  "minimatch": "^10.0.1",
76
78
  "stylelint": "^16.14.1",
77
79
  "vscode-css-languageservice": "^6.3.2",
@@ -85,10 +87,10 @@
85
87
  "@types/color-rgba": "^2.1.3",
86
88
  "@types/mocha": "^10.0.10",
87
89
  "@types/node": "^22.13.1",
88
- "@typescript-eslint/eslint-plugin": "^8.23.0",
89
- "@typescript-eslint/parser": "^8.23.0",
90
+ "@typescript-eslint/eslint-plugin": "^8.29.0",
91
+ "@typescript-eslint/parser": "^8.29.0",
90
92
  "color-rgba": "^3.0.0",
91
- "esbuild": "^0.25.0",
93
+ "esbuild": "^0.25.2",
92
94
  "eslint": "^8.57.1",
93
95
  "eslint-plugin-es-x": "^8.4.1",
94
96
  "eslint-plugin-eslint-comments": "^3.2.0",
@@ -103,7 +105,7 @@
103
105
  "mocha": "^11.1.0",
104
106
  "nyc": "^17.1.0",
105
107
  "stylelint-config-recommended": "^15.0.0",
106
- "typescript": "^5.7.3",
108
+ "typescript": "^5.8.2",
107
109
  "v8r": "^4.2.1",
108
110
  "vscode-languageserver-textdocument": "^1.0.12"
109
111
  },