wikiparser-node 1.22.1 → 1.24.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 (100) hide show
  1. package/README.md +3 -3
  2. package/bin/config.js +2 -2
  3. package/bundle/bundle-es8.min.js +24 -24
  4. package/config/default.json +6 -0
  5. package/config/enwiki.json +2 -2
  6. package/config/llwiki.json +382 -261
  7. package/config/moegirl.json +325 -325
  8. package/coverage/badge.svg +1 -1
  9. package/dist/base.d.mts +18 -2
  10. package/dist/base.d.ts +18 -2
  11. package/dist/bin/config.js +17 -5
  12. package/dist/index.d.ts +3 -2
  13. package/dist/index.js +3 -6
  14. package/dist/lib/element.d.ts +10 -64
  15. package/dist/lib/element.js +28 -135
  16. package/dist/lib/lsp.d.ts +19 -1
  17. package/dist/lib/lsp.js +131 -16
  18. package/dist/lib/node.d.ts +5 -9
  19. package/dist/lib/node.js +26 -24
  20. package/dist/lib/range.d.ts +90 -4
  21. package/dist/lib/range.js +596 -391
  22. package/dist/lib/text.d.ts +17 -16
  23. package/dist/lib/text.js +78 -62
  24. package/dist/lib/title.js +5 -4
  25. package/dist/mixin/attributesParent.js +3 -13
  26. package/dist/mixin/elementLike.d.ts +65 -0
  27. package/dist/mixin/elementLike.js +96 -0
  28. package/dist/mixin/fixed.js +2 -3
  29. package/dist/mixin/gapped.js +2 -2
  30. package/dist/mixin/hidden.js +2 -2
  31. package/dist/mixin/multiLine.js +2 -2
  32. package/dist/mixin/noEscape.js +4 -2
  33. package/dist/mixin/nodeLike.d.ts +17 -0
  34. package/dist/mixin/nodeLike.js +29 -0
  35. package/dist/mixin/padded.js +2 -1
  36. package/dist/mixin/singleLine.js +2 -1
  37. package/dist/mixin/sol.js +2 -2
  38. package/dist/mixin/syntax.js +2 -2
  39. package/dist/parser/commentAndExt.js +7 -8
  40. package/dist/parser/externalLinks.js +2 -2
  41. package/dist/parser/hrAndDoubleUnderscore.js +8 -5
  42. package/dist/parser/selector.js +3 -0
  43. package/dist/src/arg.js +4 -4
  44. package/dist/src/atom.d.ts +1 -1
  45. package/dist/src/attribute.d.ts +1 -1
  46. package/dist/src/attribute.js +11 -10
  47. package/dist/src/attributes.js +4 -4
  48. package/dist/src/converter.js +1 -1
  49. package/dist/src/converterFlags.js +2 -2
  50. package/dist/src/gallery.js +8 -7
  51. package/dist/src/heading.js +16 -7
  52. package/dist/src/html.d.ts +8 -0
  53. package/dist/src/html.js +36 -14
  54. package/dist/src/imageParameter.js +2 -2
  55. package/dist/src/imagemap.js +2 -2
  56. package/dist/src/index.d.ts +5 -1
  57. package/dist/src/index.js +3 -2
  58. package/dist/src/link/base.js +5 -18
  59. package/dist/src/link/file.js +14 -5
  60. package/dist/src/link/galleryImage.js +2 -2
  61. package/dist/src/link/index.js +6 -3
  62. package/dist/src/link/redirectTarget.js +1 -1
  63. package/dist/src/magicLink.js +4 -4
  64. package/dist/src/nested.js +3 -3
  65. package/dist/src/nowiki/base.js +1 -1
  66. package/dist/src/nowiki/comment.js +1 -1
  67. package/dist/src/nowiki/index.js +2 -2
  68. package/dist/src/nowiki/quote.js +10 -10
  69. package/dist/src/onlyinclude.js +1 -1
  70. package/dist/src/paramTag/index.d.ts +1 -1
  71. package/dist/src/paramTag/index.js +1 -1
  72. package/dist/src/parameter.js +1 -1
  73. package/dist/src/redirect.js +2 -2
  74. package/dist/src/syntax.d.ts +1 -1
  75. package/dist/src/table/base.d.ts +3 -2
  76. package/dist/src/table/base.js +18 -15
  77. package/dist/src/table/index.d.ts +0 -1
  78. package/dist/src/table/index.js +7 -9
  79. package/dist/src/table/td.d.ts +1 -1
  80. package/dist/src/table/td.js +13 -21
  81. package/dist/src/tagPair/include.js +2 -2
  82. package/dist/src/tagPair/index.js +2 -2
  83. package/dist/src/transclude.js +9 -15
  84. package/dist/util/debug.js +2 -0
  85. package/dist/util/lint.js +89 -4
  86. package/dist/util/sharable.js +2 -2
  87. package/dist/util/sharable.mjs +2 -2
  88. package/dist/util/string.js +11 -10
  89. package/extensions/typings.d.ts +3 -1
  90. package/package.json +8 -9
  91. package/bundle/bundle-lsp.min.js +0 -32
  92. package/bundle/bundle.min.js +0 -29
  93. package/extensions/dist/base.js +0 -353
  94. package/extensions/dist/codejar.js +0 -57
  95. package/extensions/dist/editor.js +0 -159
  96. package/extensions/dist/highlight.js +0 -30
  97. package/extensions/dist/lint.js +0 -80
  98. package/extensions/dist/lsp.js +0 -83
  99. package/extensions/editor.css +0 -59
  100. package/extensions/ui.css +0 -1
@@ -228,20 +228,10 @@ let TdToken = (() => {
228
228
  const e = (0, lint_1.generateForChild)(child, rect, rule, 'additional "|" in a table cell', s);
229
229
  if (double) {
230
230
  const syntax = { caption: '|+', td: '|', th: '!' }[this.subtype];
231
- e.fix = {
232
- desc: 'newline',
233
- range: [e.startIndex, e.endIndex],
234
- text: data.replace(/\|\|/gu, `\n${syntax}`),
235
- };
231
+ e.fix = (0, lint_1.fixBy)(e, 'newline', data.replace(/\|\|/gu, `\n${syntax}`));
236
232
  }
237
233
  else {
238
- e.suggestions = [
239
- {
240
- desc: 'escape',
241
- range: [e.startIndex, e.endIndex],
242
- text: data.replace(/\|/gu, '|'),
243
- },
244
- ];
234
+ e.suggestions = [(0, lint_1.fixByPipe)(e.startIndex, data)];
245
235
  }
246
236
  errors.push(e);
247
237
  }
@@ -263,6 +253,17 @@ let TdToken = (() => {
263
253
  key = (0, string_1.trimLc)(key);
264
254
  return (key === 'rowspan' || key === 'colspan' ? parseInt(value) || 1 : value);
265
255
  }
256
+ escape() {
257
+ LSP: { // eslint-disable-line no-unused-labels
258
+ super.escape();
259
+ if (this.childNodes[1].toString()) {
260
+ this.#innerSyntax ||= '{{!}}';
261
+ }
262
+ if (this.#innerSyntax === '|') {
263
+ this.#innerSyntax = '{{!}}';
264
+ }
265
+ }
266
+ }
266
267
  /** @private */
267
268
  print() {
268
269
  const { childNodes: [syntax, attr, inner] } = this;
@@ -345,15 +346,6 @@ let TdToken = (() => {
345
346
  this.#innerSyntax = '';
346
347
  }
347
348
  }
348
- escape() {
349
- super.escape();
350
- if (this.childNodes[1].toString()) {
351
- this.#innerSyntax ||= '{{!}}';
352
- }
353
- if (this.#innerSyntax === '|') {
354
- this.#innerSyntax = '{{!}}';
355
- }
356
- }
357
349
  /** @private */
358
350
  toHtmlInternal(opt) {
359
351
  const { subtype, childNodes: [, attr, inner], nextSibling } = this, notEOL = nextSibling?.toString().startsWith('\n') === false, lf = opt?.nowrap ? ' ' : '\n';
@@ -104,12 +104,12 @@ let IncludeToken = (() => {
104
104
  const errors = [], { firstChild, closed, name } = this, rect = new rect_1.BoundingRect(this, start), rules = ['no-ignored', 'unclosed-comment'], s = rules.map(rule => index_1.default.lintConfig.getSeverity(rule, 'include'));
105
105
  if (s[0] && firstChild.data.trim()) {
106
106
  const e = (0, lint_1.generateForChild)(firstChild, rect, rules[0], 'useless attribute', s[0]);
107
- e.suggestions = [{ desc: 'remove', range: [e.startIndex, e.endIndex], text: '' }];
107
+ e.suggestions = [(0, lint_1.fixByRemove)(e)];
108
108
  errors.push(e);
109
109
  }
110
110
  if (s[1] && !closed) {
111
111
  const e = (0, lint_1.generateForSelf)(this, rect, rules[1], index_1.default.msg('unclosed $1', `<${name}>`), s[1]);
112
- e.suggestions = [{ desc: 'close', range: [e.endIndex, e.endIndex], text: `</${name}>` }];
112
+ e.suggestions = [(0, lint_1.fixByClose)(e.endIndex, `</${name}>`)];
113
113
  errors.push(e);
114
114
  }
115
115
  return errors;
@@ -39,11 +39,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
40
  exports.TagPairToken = void 0;
41
41
  const gapped_1 = require("../../mixin/gapped");
42
+ const noEscape_1 = require("../../mixin/noEscape");
42
43
  const index_1 = require("../index");
43
44
  /* NOT FOR BROWSER */
44
45
  const constants_1 = require("../../util/constants");
45
46
  const fixed_1 = require("../../mixin/fixed");
46
- const noEscape_1 = require("../../mixin/noEscape");
47
47
  const index_2 = __importDefault(require("../../index"));
48
48
  /* NOT FOR BROWSER END */
49
49
  /**
@@ -52,7 +52,7 @@ const index_2 = __importDefault(require("../../index"));
52
52
  * 成对标签
53
53
  */
54
54
  let TagPairToken = (() => {
55
- let _classDecorators = [fixed_1.fixedToken, noEscape_1.noEscape, (0, gapped_1.gapped)()];
55
+ let _classDecorators = [fixed_1.fixedToken, (0, gapped_1.gapped)(), noEscape_1.noEscape];
56
56
  let _classDescriptor;
57
57
  let _classExtraInitializers = [];
58
58
  let _classThis;
@@ -44,13 +44,13 @@ const debug_1 = require("../util/debug");
44
44
  const constants_1 = require("../util/constants");
45
45
  const rect_1 = require("../lib/rect");
46
46
  const gapped_1 = require("../mixin/gapped");
47
+ const noEscape_1 = require("../mixin/noEscape");
47
48
  const index_1 = __importDefault(require("../index"));
48
49
  const index_2 = require("./index");
49
50
  const parameter_1 = require("./parameter");
50
51
  const atom_1 = require("./atom");
51
52
  const syntax_1 = require("./syntax");
52
53
  /* NOT FOR BROWSER */
53
- const noEscape_1 = require("../mixin/noEscape");
54
54
  const cached_1 = require("../mixin/cached");
55
55
  const basicMagicWords = new Map([['=', '='], ['!', '|']]);
56
56
  /**
@@ -306,10 +306,11 @@ let TranscludeToken = (() => {
306
306
  }
307
307
  /** @private */
308
308
  toString(skip) {
309
- return `{{${this.modifier}${this.type === 'magic-word'
310
- ? this.firstChild.toString(skip)
311
- + (this.length === 1 ? '' : this.#colon)
312
- + this.childNodes.slice(1).map(child => child.toString(skip)).join('|')
309
+ const { childNodes, length, firstChild, modifier, type } = this;
310
+ return `{{${modifier}${type === 'magic-word'
311
+ ? firstChild.toString(skip)
312
+ + (length === 1 ? '' : this.#colon)
313
+ + childNodes.slice(1).map(child => child.toString(skip)).join('|')
313
314
  : super.toString(skip, '|')}}}`;
314
315
  }
315
316
  /** @private */
@@ -365,14 +366,7 @@ let TranscludeToken = (() => {
365
366
  .findIndex(c => c.type === 'text' && (0, string_1.decodeHtml)(c.data).includes('#')), textNode = child.childNodes[i];
366
367
  if (textNode) {
367
368
  const e = (0, lint_1.generateForChild)(child, rect, rule, 'useless fragment', s);
368
- e.fix = {
369
- desc: 'remove',
370
- range: [
371
- e.startIndex + child.getRelativeIndex(i) + textNode.data.indexOf('#'),
372
- e.endIndex,
373
- ],
374
- text: '',
375
- };
369
+ e.suggestions = [(0, lint_1.fixByRemove)(e, child.getRelativeIndex(i) + textNode.data.indexOf('#'))];
376
370
  errors.push(e);
377
371
  }
378
372
  }
@@ -390,7 +384,7 @@ let TranscludeToken = (() => {
390
384
  for (const [, args] of duplicatedArgs) {
391
385
  errors.push(...args.map(arg => {
392
386
  const e = (0, lint_1.generateForChild)(arg, rect, rule, msg, s);
393
- e.suggestions = [{ desc: 'remove', range: [e.startIndex - 1, e.endIndex], text: '' }];
387
+ e.suggestions = [(0, lint_1.fixByRemove)(e, -1)];
394
388
  return e;
395
389
  }));
396
390
  }
@@ -636,7 +630,7 @@ let TranscludeToken = (() => {
636
630
  * @param exact whether to match anonymosity / 是否匹配匿名性
637
631
  */
638
632
  getArg(key, exact) {
639
- return [...this.getArgs(key, exact, false)].sort((a, b) => a.compareDocumentPosition(b)).at(-1);
633
+ return [...this.getArgs(key, exact, false)].sort((a, b) => b.compareDocumentPosition(a))[0];
640
634
  }
641
635
  /**
642
636
  * Remove parameters with the specified name
@@ -62,6 +62,7 @@ const setChildNodes = (parent, position, deleteCount, inserted = []) => {
62
62
  return removed;
63
63
  };
64
64
  exports.setChildNodes = setChildNodes;
65
+ /* NOT FOR BROWSER ONLY */
65
66
  /**
66
67
  * 同步混入的类名
67
68
  * @param target 混入的目标
@@ -71,6 +72,7 @@ const mixin = (target, source) => {
71
72
  Object.defineProperty(target, 'name', { value: source.name });
72
73
  };
73
74
  exports.mixin = mixin;
75
+ /* NOT FOR BROWSER ONLY END */
74
76
  /* NOT FOR BROWSER */
75
77
  /**
76
78
  * 撤销最近一次Mutation
package/dist/util/lint.js CHANGED
@@ -3,7 +3,8 @@ 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.provideValues = exports.cache = exports.generateForSelf = exports.generateForChild = exports.getEndPos = exports.isFostered = void 0;
6
+ exports.provideValues = exports.cache = exports.fixByPipe = exports.fixByEscape = exports.fixBySpace = exports.fixByUpper = exports.fixByComment = exports.fixByOpen = exports.fixByClose = exports.fixByDecode = exports.fixByRemove = exports.fixByInsert = exports.fixBy = exports.generateForSelf = exports.generateForChild = exports.getEndPos = exports.isFostered = void 0;
7
+ const common_1 = require("@bhsd/common");
7
8
  const debug_1 = require("./debug");
8
9
  const rect_1 = require("../lib/rect");
9
10
  const index_1 = __importDefault(require("../index"));
@@ -76,6 +77,92 @@ exports.generateForChild = factory((child, start, line, col) => {
76
77
  };
77
78
  });
78
79
  exports.generateForSelf = factory((_, startIndex, startLine, startCol) => ({ startIndex, startLine, startCol }));
80
+ /**
81
+ * Quick fix
82
+ * @param e LintError
83
+ * @param desc description of the fix
84
+ * @param text replacement text
85
+ * @param offset offset to the start index
86
+ */
87
+ const fixBy = (e, desc, text, offset = 0) => ({ desc, range: [e.startIndex + offset, e.endIndex], text });
88
+ exports.fixBy = fixBy;
89
+ /**
90
+ * Quick fix: insert the text
91
+ * @param index the index to insert the text
92
+ * @param desc description of the fix
93
+ * @param text inserted text
94
+ */
95
+ const fixByInsert = (index, desc, text) => ({ desc, range: [index, index], text });
96
+ exports.fixByInsert = fixByInsert;
97
+ /**
98
+ * Quick fix: remove the error
99
+ * @param e LintError
100
+ * @param offset offset to the start index
101
+ * @param text replacement text
102
+ */
103
+ const fixByRemove = (e, offset = 0, text = '') => typeof e === 'number' ? { desc: 'remove', range: [e, e + offset], text } : (0, exports.fixBy)(e, 'remove', text, offset);
104
+ exports.fixByRemove = fixByRemove;
105
+ /**
106
+ * Quick fix: decode the link
107
+ * @param e LintError
108
+ * @param link the link to decode
109
+ */
110
+ const fixByDecode = (e, link) => (0, exports.fixBy)(e, 'decode', (0, common_1.rawurldecode)(link.text().replace(/%(?=21|3[ce]|5[bd]|7[b-d])/giu, '%25')));
111
+ exports.fixByDecode = fixByDecode;
112
+ /**
113
+ * Quick fix: close the syntax
114
+ * @param index the index to insert the closing syntax
115
+ * @param text the closing syntax text
116
+ * @param offset offset to the start index
117
+ */
118
+ const fixByClose = (index, text, offset = 0) => ({ desc: 'close', range: [index + offset, index], text });
119
+ exports.fixByClose = fixByClose;
120
+ /**
121
+ * Quick fix: open the syntax
122
+ * @param index the index of the tag to open
123
+ */
124
+ const fixByOpen = (index) => ({ desc: 'open', range: [index + 1, index + 2], text: '' });
125
+ exports.fixByOpen = fixByOpen;
126
+ /**
127
+ * Quick fix: comment out
128
+ * @param e LintError
129
+ * @param text the closing syntax text
130
+ */
131
+ const fixByComment = (e, text) => (0, exports.fixBy)(e, 'comment', `<!--${text}-->`);
132
+ exports.fixByComment = fixByComment;
133
+ /**
134
+ * Quick fix: convert to upper case
135
+ * @param e LintError
136
+ * @param text the closing syntax text
137
+ */
138
+ const fixByUpper = (e, text) => (0, exports.fixBy)(e, 'uppercase', text.toUpperCase());
139
+ exports.fixByUpper = fixByUpper;
140
+ /**
141
+ * Quick fix: insert space
142
+ * @param index the index to insert the space
143
+ * @param offset offset to the end index
144
+ */
145
+ const fixBySpace = (index, offset = 0) => ({ desc: 'whitespace', range: [index, index + offset], text: ' ' });
146
+ exports.fixBySpace = fixBySpace;
147
+ /**
148
+ * Quick fix: escape the character
149
+ * @param index the index to escape the character
150
+ * @param char the escaped character
151
+ * @param offset offset to the end index
152
+ */
153
+ const fixByEscape = (index, char, offset = 1) => ({ desc: 'escape', range: [index, index + offset], text: char.repeat(offset) });
154
+ exports.fixByEscape = fixByEscape;
155
+ /**
156
+ * Quick fix: escape the `|` character
157
+ * @param index the index to escape the character
158
+ * @param text the text to be replaced
159
+ */
160
+ const fixByPipe = (index, text) => ({
161
+ desc: 'escape',
162
+ range: [index, index + text.length],
163
+ text: text.replace(/\|/gu, '&#124;'),
164
+ });
165
+ exports.fixByPipe = fixByPipe;
79
166
  /**
80
167
  * 缓存计算结果
81
168
  * @param store 缓存的值
@@ -84,9 +171,7 @@ exports.generateForSelf = factory((_, startIndex, startLine, startCol) => ({ sta
84
171
  * @param force 是否强制缓存
85
172
  */
86
173
  const cache = (store, compute, update, force) => {
87
- if (store
88
- /* PRINT ONLY */
89
- && (force || index_1.default.viewOnly && store[0] === debug_1.Shadow.rev)) {
174
+ if (store && (force || index_1.default.viewOnly && store[0] === debug_1.Shadow.rev)) {
90
175
  return store[1];
91
176
  }
92
177
  const result = compute();
@@ -78,7 +78,7 @@ exports.commonHtmlAttrs = new Set([
78
78
  math: empty,
79
79
  chem: empty,
80
80
  ce: empty,
81
- img: new Set(['alt', 'src', 'width', 'height', 'loading']),
81
+ img: new Set(['alt', 'src', 'width', 'height', 'loading', 'srcset']),
82
82
  }))(), exports.extAttrs = (() => ({
83
83
  gallery: new Set(['mode', 'showfilename', 'caption', 'perrow', 'widths', 'heights', 'showthumbnails']),
84
84
  poem: new Set(['compact']),
@@ -96,7 +96,7 @@ exports.commonHtmlAttrs = new Set([
96
96
  nowiki: empty,
97
97
  indicator: new Set(['name']),
98
98
  langconvert: new Set(['from', 'to']),
99
- ref: new Set(['group', 'name', 'extends', 'follow', 'dir']),
99
+ ref: new Set(['group', 'name', 'follow', 'dir', 'details']),
100
100
  references: new Set(['group', 'responsive']),
101
101
  charinsert: new Set(['label']),
102
102
  choose: new Set(['uncached', 'before', 'after']),
@@ -76,7 +76,7 @@ const commonHtmlAttrs = /* @__PURE__ */ new Set([
76
76
  math: empty,
77
77
  chem: empty,
78
78
  ce: empty,
79
- img: /* @__PURE__ */ new Set(["alt", "src", "width", "height", "loading"])
79
+ img: /* @__PURE__ */ new Set(["alt", "src", "width", "height", "loading", "srcset"])
80
80
  }))(), extAttrs = /* @__PURE__ */ (() => ({
81
81
  gallery: /* @__PURE__ */ new Set(["mode", "showfilename", "caption", "perrow", "widths", "heights", "showthumbnails"]),
82
82
  poem: /* @__PURE__ */ new Set(["compact"]),
@@ -94,7 +94,7 @@ const commonHtmlAttrs = /* @__PURE__ */ new Set([
94
94
  nowiki: empty,
95
95
  indicator: /* @__PURE__ */ new Set(["name"]),
96
96
  langconvert: /* @__PURE__ */ new Set(["from", "to"]),
97
- ref: /* @__PURE__ */ new Set(["group", "name", "extends", "follow", "dir"]),
97
+ ref: /* @__PURE__ */ new Set(["group", "name", "follow", "dir", "details"]),
98
98
  references: /* @__PURE__ */ new Set(["group", "responsive"]),
99
99
  charinsert: /* @__PURE__ */ new Set(["label"]),
100
100
  choose: /* @__PURE__ */ new Set(["uncached", "before", "after"]),
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.removeCommentLine = exports.newline = exports.sanitizeAlt = exports.sanitizeId = exports.sanitizeAttr = exports.sanitize = exports.normalizeSpace = exports.encode = exports.noWrap = exports.escapeRegExp = exports.print = exports.escape = exports.decodeNumber = exports.decodeHtml = exports.decodeHtmlBasic = exports.text = exports.removeComment = exports.tidy = exports.restore = exports.trimLc = exports.extUrlChar = exports.extUrlCharFirst = exports.zs = exports.rawurldecode = void 0;
4
- var common_1 = require("@bhsd/common");
5
- Object.defineProperty(exports, "rawurldecode", { enumerable: true, get: function () { return common_1.rawurldecode; } });
3
+ exports.removeCommentLine = exports.newline = exports.sanitizeAlt = exports.sanitizeId = exports.sanitizeAttr = exports.sanitize = exports.normalizeSpace = exports.encode = exports.noWrap = exports.escapeRegExp = exports.print = exports.escape = exports.decodeNumber = exports.decodeHtml = exports.decodeHtmlBasic = exports.text = exports.removeComment = exports.tidy = exports.trimLc = exports.extUrlChar = exports.extUrlCharFirst = exports.zs = void 0;
4
+ exports.restore = restore;
6
5
  exports.zs = String.raw ` \xA0\u1680\u2000-\u200A\u202F\u205F\u3000`;
7
6
  const commonExtUrlChar = String.raw `[^[\]<>"\0-\x1F\x7F${exports.zs}\uFFFD]`;
8
7
  exports.extUrlCharFirst = String.raw `(?:\[[\da-f:.]+\]|${commonExtUrlChar})`;
@@ -13,13 +12,15 @@ exports.extUrlChar = String.raw `(?:${commonExtUrlChar}|\0\d+[cn!~]\x7F)*`;
13
12
  */
14
13
  const trimLc = (s) => s.trim().toLowerCase();
15
14
  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;
15
+ function restore(s, stack, translate) {
16
+ if (translate === 1) {
17
+ return s.replace(/\0(\d+)g\x7F/gu, (_, p1) => restore(String(stack[p1]), stack, 2));
18
+ }
19
+ else if (translate === 2) {
20
+ return s.replace(/\0(\d+)n\x7F/gu, (_, p1) => String(stack[p1]));
21
+ }
22
+ return s.replace(/\0(\d+)\x7F/gu, (_, p1) => stack[p1]);
23
+ }
23
24
  /**
24
25
  * 生成正则替换函数
25
26
  * @param regex 正则表达式
@@ -6,6 +6,7 @@ import type {CodeJar} from 'codejar-async';
6
6
  import type {
7
7
  ColorInformation,
8
8
  ColorPresentation,
9
+ CodeAction,
9
10
  } from 'vscode-languageserver-types';
10
11
  // 必须写在一行内
11
12
  import type {Config, ConfigData, LintConfig, LintError, AST, LanguageService} from '../base';
@@ -32,10 +33,11 @@ export type codejar = (textbox: HTMLTextAreaElement, include?: boolean, linenums
32
33
 
33
34
  export interface LanguageServiceBase extends Omit<
34
35
  LanguageService,
35
- 'provideDocumentSymbols' | 'provideCodeAction' | 'findStyleTokens'
36
+ 'provideDocumentSymbols' | 'provideCodeAction'
36
37
  > {
37
38
  provideDocumentColors(text: string): Promise<ColorInformation[]>;
38
39
  provideColorPresentations(color: ColorInformation): Promise<ColorPresentation[]>;
40
+ resolveCodeAction(rule?: string): Promise<CodeAction>;
39
41
  findStyleTokens(): Promise<AST[]>;
40
42
  }
41
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikiparser-node",
3
- "version": "1.22.1",
3
+ "version": "1.24.0",
4
4
  "description": "A Node.js parser for MediaWiki markup with AST",
5
5
  "keywords": [
6
6
  "mediawiki",
@@ -46,7 +46,6 @@
46
46
  },
47
47
  "scripts": {
48
48
  "toc": "node dist/script/toc.js",
49
- "declaration": "grep -rl --include='*.d.ts' '@private' dist/ | xargs bash sed.sh -i -E '/^\\s+\\/\\*\\* @private/,+1d'; grep -rl --include='*.d.ts' '/util/' dist/ | xargs bash sed.sh -i -E '/^import .+\\/util\\//d'; bash sed.sh -i -E 's/abstract (lint|print|text)\\b/\\1/' dist/lib/node.d.ts; node dist/script/declaration.js",
50
49
  "prepublishOnly": "npm run build:core",
51
50
  "build:core": "bash build.sh",
52
51
  "build": "npm run build:core && node dist/script/parserTests.js",
@@ -77,9 +76,9 @@
77
76
  ]
78
77
  },
79
78
  "dependencies": {
80
- "@bhsd/cm-util": "^0.0.0",
81
- "@bhsd/common": "^1.0.0",
82
- "@bhsd/stylelint-util": "^0.0.0",
79
+ "@bhsd/cm-util": "^0.0.1",
80
+ "@bhsd/common": "^1.0.1",
81
+ "@bhsd/stylelint-util": "^0.1.0",
83
82
  "vscode-languageserver-types": "^3.17.5"
84
83
  },
85
84
  "optionalDependencies": {
@@ -87,14 +86,14 @@
87
86
  "color-name": "^2.0.0",
88
87
  "entities": "^6.0.0",
89
88
  "mathjax": "^3.2.2",
90
- "stylelint": "^16.22.0",
89
+ "stylelint": "^16.23.1",
91
90
  "vscode-css-languageservice": "^6.3.7",
92
91
  "vscode-html-languageservice": "^5.5.1",
93
92
  "vscode-json-languageservice": "^5.6.1"
94
93
  },
95
94
  "devDependencies": {
96
- "@bhsd/code-standard": "^1.0.0",
97
- "@bhsd/test-util": "^0.0.0",
95
+ "@bhsd/code-standard": "^1.0.1",
96
+ "@bhsd/test-util": "^0.1.0",
98
97
  "@codemirror/lint": "^6.8.5",
99
98
  "@stylistic/eslint-plugin": "^3.1.0",
100
99
  "@types/color-name": "^2.0.0",
@@ -108,7 +107,7 @@
108
107
  "esbuild": "^0.25.5",
109
108
  "eslint": "^8.57.1",
110
109
  "eslint-plugin-eslint-comments": "^3.2.0",
111
- "eslint-plugin-jsdoc": "^51.3.3",
110
+ "eslint-plugin-jsdoc": "^52.0.2",
112
111
  "eslint-plugin-json-es": "^1.6.0",
113
112
  "eslint-plugin-markdown": "5.1.0",
114
113
  "eslint-plugin-n": "^17.20.0",