wikiparser-node 1.3.3 → 1.3.4

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/README.en.md CHANGED
@@ -18,7 +18,7 @@ This version provides a [CLI](https://en.wikipedia.org/wiki/Command-line_interfa
18
18
 
19
19
  ## Browser-compatible
20
20
 
21
- A browser-compatible version, which can be used for code highlighting or as a linting plugin in conjunction with the [CodeMirror5](https://codemirror.net/5/) editor. ([Usage example](https://bhsd-harry.github.io/wikiparser-node))
21
+ A browser-compatible version, which can be used for code highlighting or as a linting plugin in conjunction with the [CodeMirror](https://codemirror.net/) editor. ([Usage example](https://bhsd-harry.github.io/wikiparser-node))
22
22
 
23
23
  # Installation
24
24
 
package/README.md CHANGED
@@ -18,7 +18,7 @@ wikiparser-node 是一款由 Bhsd 开发的基于 [Node.js](https://nodejs.org/)
18
18
 
19
19
  ## Browser-compatible
20
20
 
21
- 兼容浏览器的版本,可用于代码高亮或是搭配 [CodeMirror5](https://codemirror.net/5/) 编辑器作为语法分析插件。([使用实例展示](https://bhsd-harry.github.io/wikiparser-node))
21
+ 兼容浏览器的版本,可用于代码高亮或是搭配 [CodeMirror](https://codemirror.net/) 编辑器作为语法分析插件。([使用实例展示](https://bhsd-harry.github.io/wikiparser-node))
22
22
 
23
23
  # 安装方法
24
24
 
@@ -64,7 +64,7 @@ class MagicLinkToken extends (0, syntax_1.syntax)(index_1.Token) {
64
64
  rect ??= { start, ...this.getRootNode().posFromIndex(start) };
65
65
  const refError = (0, lint_1.generateForChild)(child, rect, '', 'warning');
66
66
  errors.push(...[...data.matchAll(regexGlobal)].map(({ index, 0: s }) => {
67
- const lines = data.slice(0, index).split('\n'), { length: top } = lines, { length: left } = lines.at(-1), startIndex = start + index, startLine = refError.startLine + top - 1, startCol = top === 1 ? refError.startCol + left : left;
67
+ const lines = data.slice(0, index).split('\n'), { length: top } = lines, { length: left } = lines.at(-1), startIndex = refError.startIndex + index, startLine = refError.startLine + top - 1, startCol = top === 1 ? refError.startCol + left : left;
68
68
  return {
69
69
  ...refError,
70
70
  message: Parser.msg('$1 in URL', s.startsWith('|') ? '"|"' : Parser.msg('full-width punctuation')),
@@ -10,6 +10,14 @@ const index_1 = require("./index");
10
10
  const parameter_1 = require("./parameter");
11
11
  const atom_1 = require("./atom");
12
12
  const syntax_1 = require("./syntax");
13
+ const insensitiveVars = new Set([
14
+ 'pageid',
15
+ 'articlepath',
16
+ 'server',
17
+ 'servername',
18
+ 'scriptpath',
19
+ 'stylepath',
20
+ ]);
13
21
  /**
14
22
  * 模板或魔术字
15
23
  * @classdesc `{childNodes: [AtomToken|SyntaxToken, ...AtomToken, ...ParameterToken]}`
@@ -55,9 +63,9 @@ class TranscludeToken extends index_1.Token {
55
63
  }
56
64
  const isFunction = title.includes(':');
57
65
  if (isFunction || parts.length === 0 && !this.#raw) {
58
- const [magicWord, ...arg] = title.split(':'), cleaned = (0, string_1.removeComment)(magicWord), name = cleaned[arg.length > 0 ? 'trimStart' : 'trim'](), isSensitive = sensitive.includes(name), canonicalCame = isFunction && insensitive[name.toLowerCase()];
59
- if (isSensitive || canonicalCame) {
60
- this.setAttribute('name', canonicalCame || name.toLowerCase());
66
+ const [magicWord, ...arg] = title.split(':'), cleaned = (0, string_1.removeComment)(magicWord), name = cleaned[arg.length > 0 ? 'trimStart' : 'trim'](), lcName = name.toLowerCase(), canonicalName = insensitive[lcName], isSensitive = sensitive.includes(name), isVar = isSensitive || insensitiveVars.has(canonicalName);
67
+ if (isVar || isFunction && canonicalName) {
68
+ this.setAttribute('name', canonicalName ?? lcName);
61
69
  this.type = 'magic-word';
62
70
  const pattern = new RegExp(`^\\s*${name}\\s*$`, isSensitive ? 'u' : 'iu'), token = new syntax_1.SyntaxToken(magicWord, pattern, 'magic-word-name', config, accum, {
63
71
  'Stage-1': ':', '!ExtToken': '',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikiparser-node",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "description": "A Node.js parser for MediaWiki markup with AST",
5
5
  "keywords": [
6
6
  "mediawiki",