wikiparser-node 1.20.2 → 1.20.3

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.
@@ -116,7 +116,6 @@ exports.default = async (site, url, force, internal) => {
116
116
  ...ns.map(([id, canonical]) => [canonical.toLowerCase(), Number(id)]),
117
117
  ...namespacealiases.filter(({ id }) => filterGadget(id)).map(({ id, alias }) => [alias.toLowerCase(), id]),
118
118
  ]),
119
- functionHook: [...functionhooks.map(s => s.toLowerCase()), 'msgnw'],
120
119
  articlePath: articlepath,
121
120
  };
122
121
  config.doubleUnderscore[0] = [];
@@ -124,6 +123,9 @@ exports.default = async (site, url, force, internal) => {
124
123
  Object.assign(config.parserFunction[0], (0, cm_1.getConfig)(magicwords, ({ name }) => name === 'msgnw'));
125
124
  config.parserFunction[2] = getAliases(magicwords, new Set(['msg', 'raw']));
126
125
  config.parserFunction[3] = getAliases(magicwords, new Set(['subst', 'safesubst']));
126
+ if (!mwConfig.functionHooks) {
127
+ Object.assign(config, { functionHook: [...functionhooks.map(s => s.toLowerCase()), 'msgnw'] });
128
+ }
127
129
  if (!mwConfig.variableIDs) {
128
130
  const { query: { variables } } = await (await fetch(`${url}/api.php?${new URLSearchParams({ ...params, siprop: 'variables' }).toString()}`)).json();
129
131
  Object.assign(config, { variable: [...new Set([...variables, '='])] });
package/dist/lib/text.js CHANGED
@@ -211,6 +211,7 @@ let AstText = (() => {
211
211
  isHtmlAttrVal = true;
212
212
  }
213
213
  else if (tag === 'ref' && (grandName === 'name' || grandName === 'extends' || grandName === 'follow')
214
+ || grandName === 'group' && (tag === 'ref' || tag === 'references')
214
215
  || tag === 'choose' && (grandName === 'before' || grandName === 'after')) {
215
216
  return [];
216
217
  }
@@ -226,7 +227,7 @@ let AstText = (() => {
226
227
  return [];
227
228
  }
228
229
  errorRegex.lastIndex = 0;
229
- const errors = [], nextType = nextSibling?.type, nextName = nextSibling?.name, previousType = previousSibling?.type, root = this.getRootNode(), rootStr = root.toString(), { ext, html } = root.getAttribute('config'), { top, left } = root.posFromIndex(start), tags = new Set([
230
+ const errors = [], nextType = nextSibling?.type, nextName = nextSibling?.name, previousType = previousSibling?.type, root = this.getRootNode(), rootStr = root.toString(), { ext, html, variants } = root.getAttribute('config'), { top, left } = root.posFromIndex(start), tags = new Set([
230
231
  'onlyinclude',
231
232
  'noinclude',
232
233
  'includeonly',
@@ -245,7 +246,8 @@ let AstText = (() => {
245
246
  error = error.slice(length);
246
247
  }
247
248
  error = error.toLowerCase();
248
- const { 0: char, length } = error, magicLink = char === 'r' || char === 'p' || char === 'i';
249
+ const [char] = error, magicLink = char === 'r' || char === 'p' || char === 'i';
250
+ let { length } = error;
249
251
  if (char === '<' && !tags.has(tag.toLowerCase())
250
252
  || char === '[' && type === 'ext-link-text' && (/&(?:rbrack|#93|#x5[Dd];);/u.test(data.slice(index + 1))
251
253
  || nextSibling?.is('ext') && nextName === 'nowiki'
@@ -256,12 +258,14 @@ let AstText = (() => {
256
258
  else if (char === ']' && (index || length > 1)) {
257
259
  errorRegex.lastIndex--;
258
260
  }
259
- const startIndex = start + index, endIndex = startIndex + length, nextChar = rootStr[endIndex], previousChar = rootStr[startIndex - 1], severity = length > 1 && !(char === '<' && (/^<\s/u.test(error) || !/[\s/>]/u.test(nextChar ?? '') || disallowedTags.has(tag))
261
+ let startIndex = start + index, endIndex = startIndex + length;
262
+ const nextChar = rootStr[endIndex], previousChar = rootStr[startIndex - 1];
263
+ let severity = length > 1 && !(char === '<' && (/^<\s/u.test(error) || !/[\s/>]/u.test(nextChar ?? '') || disallowedTags.has(tag))
260
264
  || isHtmlAttrVal && (char === '[' || char === ']')
261
265
  || magicLink && type === 'parameter-value'
262
266
  || /^(?:rfc|pmid|isbn)$/iu.test(error))
263
- || char === '{' && (nextChar === char || previousChar === '-')
264
- || char === '}' && (previousChar === char || nextChar === '-')
267
+ || char === '{' && (nextChar === char || previousChar === '-' && variants.length > 0)
268
+ || char === '}' && (previousChar === char || nextChar === '-' && variants.length > 0)
265
269
  || char === '[' && (type === 'ext-link-text' || nextType === 'free-ext-link' && !data.slice(index + 1).trim())
266
270
  || char === ']' && previousType === 'free-ext-link'
267
271
  && !data.slice(0, index).includes(']')
@@ -288,9 +292,26 @@ let AstText = (() => {
288
292
  if (magicLink) {
289
293
  error = error.toUpperCase();
290
294
  }
295
+ else if (error === '{' && previousChar === '-' && severity === 'error') {
296
+ severity = 'warning';
297
+ if (index > 0) {
298
+ error = '-{';
299
+ index--;
300
+ startIndex--;
301
+ length = 2;
302
+ }
303
+ }
304
+ else if (error === '}' && nextChar === '-' && severity === 'error') {
305
+ severity = 'warning';
306
+ if (index < data.length - 1) {
307
+ error = '}-';
308
+ endIndex++;
309
+ length = 2;
310
+ }
311
+ }
291
312
  const pos = this.posFromIndex(index), { line: startLine, character: startCol } = (0, lint_1.getEndPos)(top, left, pos.top + 1, pos.left), e = {
292
313
  rule: ruleMap[char],
293
- message: index_1.default.msg('lonely "$1"', magicLink || char === 'h' ? error : char),
314
+ message: index_1.default.msg('lonely "$1"', magicLink || char === 'h' || error === '-{' || error === '}-' ? error : char),
294
315
  severity,
295
316
  startIndex,
296
317
  endIndex,
package/dist/src/arg.js CHANGED
@@ -142,13 +142,6 @@ let ArgToken = (() => {
142
142
  /** @private */
143
143
  lint(start = this.getAbsoluteIndex(), re) {
144
144
  const { childNodes: [argName, argDefault, ...rest] } = this;
145
- if (!this.getAttribute('include')) {
146
- const e = (0, lint_1.generateForSelf)(this, { start }, 'no-arg', 'unexpected template argument');
147
- if (argDefault) {
148
- e.suggestions = [{ range: [start, e.endIndex], text: argDefault.text(), desc: 'expand' }];
149
- }
150
- return [e];
151
- }
152
145
  argName.setAttribute('aIndex', start + 3);
153
146
  const errors = argName.lint(start + 3, re);
154
147
  if (argDefault) {
@@ -172,6 +165,13 @@ let ArgToken = (() => {
172
165
  return e;
173
166
  }));
174
167
  }
168
+ if (!this.getAttribute('include')) {
169
+ const e = (0, lint_1.generateForSelf)(this, { start }, 'no-arg', 'unexpected template argument', 'warning');
170
+ if (argDefault) {
171
+ e.suggestions = [{ range: [start, e.endIndex], text: argDefault.text(), desc: 'expand' }];
172
+ }
173
+ errors.push(e);
174
+ }
175
175
  return errors;
176
176
  }
177
177
  /** @private */
@@ -233,7 +233,7 @@ let LinkBaseToken = (() => {
233
233
  }
234
234
  }
235
235
  if (fragment !== undefined && !isLink(type)) {
236
- const e = (0, lint_1.generateForChild)(target, rect, 'no-ignored', 'useless fragment'), j = target.childNodes.findIndex(c => c.type === 'text' && c.data.includes('#')), textNode = target.childNodes[j];
236
+ const e = (0, lint_1.generateForChild)(target, rect, 'no-ignored', 'useless fragment', 'warning'), j = target.childNodes.findIndex(c => c.type === 'text' && c.data.includes('#')), textNode = target.childNodes[j];
237
237
  if (textNode) {
238
238
  e.fix = {
239
239
  range: [
@@ -344,7 +344,7 @@ let TranscludeToken = (() => {
344
344
  const child = childNodes[invoke ? 1 : 0], i = child.childNodes
345
345
  .findIndex(c => c.type === 'text' && (0, string_1.decodeHtml)(c.data).includes('#')), textNode = child.childNodes[i];
346
346
  if (textNode) {
347
- const e = (0, lint_1.generateForChild)(child, rect, 'no-ignored', 'useless fragment');
347
+ const e = (0, lint_1.generateForChild)(child, rect, 'no-ignored', 'useless fragment', 'warning');
348
348
  e.fix = {
349
349
  range: [
350
350
  e.startIndex + child.getRelativeIndex(i) + textNode.data.indexOf('#'),
@@ -1,6 +1,6 @@
1
1
  (() => {
2
2
  var _a;
3
- const version = '1.20.2', 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.20.3', 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://testingcf.jsdelivr.net/npm/wikiparser-node@${version}`;
6
6
  const workerJS = () => {
package/i18n/zh-hans.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "additional \"|\" in a table cell": "表格单元格中多余的\"|\"",
5
5
  "additional \"|\" in the link text": "链接文本中多余的\"|\"",
6
6
  "attributes of a closing tag": "位于闭合标签的属性",
7
- "bold": "粗体单引号",
7
+ "bold apostrophes": "粗体单引号",
8
8
  "bold in section header": "段落标题中的粗体",
9
9
  "conflicting image $1 parameter": "冲突的图片$1参数",
10
10
  "containing invalid attribute": "包含无效属性",
@@ -35,7 +35,7 @@
35
35
  "invalid parameter of <$1>": "<$1>的无效参数",
36
36
  "invalid self-closing tag": "无效自封闭标签",
37
37
  "invisible content inside triple braces": "三重括号内的不可见部分",
38
- "italic": "斜体单引号",
38
+ "italic apostrophes": "斜体单引号",
39
39
  "lonely \"$1\"": "孤立的\"$1\"",
40
40
  "missing module function": "缺少模块函数",
41
41
  "nonzero tabindex": "不为0的tabindex",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikiparser-node",
3
- "version": "1.20.2",
3
+ "version": "1.20.3",
4
4
  "description": "A Node.js parser for MediaWiki markup with AST",
5
5
  "keywords": [
6
6
  "mediawiki",
@@ -78,7 +78,7 @@
78
78
  ]
79
79
  },
80
80
  "dependencies": {
81
- "@bhsd/common": "^0.9.4",
81
+ "@bhsd/common": "^0.10.0",
82
82
  "vscode-languageserver-types": "^3.17.5"
83
83
  },
84
84
  "optionalDependencies": {