wikilint 2.1.6 → 2.2.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.
@@ -13,7 +13,7 @@ const category_1 = require("../src/link/category");
13
13
  */
14
14
  const parseLinks = (wikitext, config = Parser.getConfig(), accum = []) => {
15
15
  const { parseQuotes } = require('./quotes');
16
- const regex = /^((?:(?!\0\d+!\x7F)[^\n<>[\]{}|])+)(?:(\||\0\d+!\x7F)(.*?[^\]]))?\]\](.*)$/su, regexImg = /^((?:(?!\0\d+!\x7F)[^\n<>[\]{}|])+)(\||\0\d+!\x7F)(.*)$/su, regexExt = new RegExp(`^\\s*(?:${config.protocol})`, 'iu'), bits = wikitext.split('[[');
16
+ const regex = /^((?:(?!\0\d+!\x7F)[^\n[\]{}|])+)(?:(\||\0\d+!\x7F)(.*?[^\]]))?\]\](.*)$/su, regexImg = /^((?:(?!\0\d+!\x7F)[^\n[\]{}|])+)(\||\0\d+!\x7F)(.*)$/su, regexExt = new RegExp(`^\\s*(?:${config.protocol})`, 'iu'), bits = wikitext.split('[[');
17
17
  let s = bits.shift();
18
18
  for (let i = 0; i < bits.length; i++) {
19
19
  let mightBeImg = false, link, delimiter, text, after;
@@ -1,20 +1,20 @@
1
1
  import * as Parser from '../index';
2
2
  import { Token } from './index';
3
3
  import { GalleryImageToken } from './link/galleryImage';
4
- import { HiddenToken } from './hidden';
4
+ import { NoincludeToken } from './nowiki/noinclude';
5
5
  import type { LintError } from '../base';
6
6
  import type { AstText, AttributesToken, ExtToken } from '../internal';
7
7
  /**
8
8
  * gallery标签
9
- * @classdesc `{childNodes: ...(GalleryImageToken|HiddenToken|AstText)}`
9
+ * @classdesc `{childNodes: ...(GalleryImageToken|NoincludeToken|AstText)}`
10
10
  */
11
11
  export declare class GalleryToken extends Token {
12
12
  #private;
13
13
  readonly type = "ext-inner";
14
14
  readonly name: 'gallery';
15
- readonly childNodes: (GalleryImageToken | HiddenToken | AstText)[];
16
- abstract get firstChild(): GalleryImageToken | HiddenToken | AstText | undefined;
17
- abstract get lastChild(): GalleryImageToken | HiddenToken | AstText | undefined;
15
+ readonly childNodes: (GalleryImageToken | NoincludeToken | AstText)[];
16
+ abstract get firstChild(): GalleryImageToken | NoincludeToken | AstText | undefined;
17
+ abstract get lastChild(): GalleryImageToken | NoincludeToken | AstText | undefined;
18
18
  abstract get nextSibling(): undefined;
19
19
  abstract get previousSibling(): AttributesToken;
20
20
  abstract get parentNode(): ExtToken | undefined;
@@ -4,10 +4,10 @@ exports.GalleryToken = void 0;
4
4
  const Parser = require("../index");
5
5
  const index_1 = require("./index");
6
6
  const galleryImage_1 = require("./link/galleryImage");
7
- const hidden_1 = require("./hidden");
7
+ const noinclude_1 = require("./nowiki/noinclude");
8
8
  /**
9
9
  * gallery标签
10
- * @classdesc `{childNodes: ...(GalleryImageToken|HiddenToken|AstText)}`
10
+ * @classdesc `{childNodes: ...(GalleryImageToken|NoincludeToken|AstText)}`
11
11
  */
12
12
  class GalleryToken extends index_1.Token {
13
13
  type = 'ext-inner';
@@ -17,9 +17,7 @@ class GalleryToken extends index_1.Token {
17
17
  for (const line of inner?.split('\n') ?? []) {
18
18
  const matches = /^([^|]+)(?:\|(.*))?/u.exec(line);
19
19
  if (!matches) {
20
- super.insertAt((line.trim()
21
- ? new hidden_1.HiddenToken(line, config, [], {})
22
- : line));
20
+ super.insertAt((line.trim() ? new noinclude_1.NoincludeToken(line, config) : line));
23
21
  continue;
24
22
  }
25
23
  const [, file, alt] = matches;
@@ -27,7 +25,7 @@ class GalleryToken extends index_1.Token {
27
25
  super.insertAt(new galleryImage_1.GalleryImageToken('gallery', file, alt, config, accum));
28
26
  }
29
27
  else {
30
- super.insertAt(new hidden_1.HiddenToken(line, config, [], {}));
28
+ super.insertAt(new noinclude_1.NoincludeToken(line, config));
31
29
  }
32
30
  }
33
31
  }
@@ -55,7 +53,7 @@ class GalleryToken extends index_1.Token {
55
53
  const { top, left } = this.getRootNode().posFromIndex(start), errors = [];
56
54
  for (let i = 0; i < this.length; i++) {
57
55
  const child = this.childNodes[i], str = String(child), { length } = str, trimmed = str.trim(), startLine = top + i, startCol = i ? 0 : left;
58
- if (child.type === 'hidden' && trimmed && !/^<!--.*-->$/u.test(trimmed)) {
56
+ if (child.type === 'noinclude' && trimmed && !/^<!--.*-->$/u.test(trimmed)) {
59
57
  errors.push({
60
58
  message: Parser.msg('invalid content in <$1>', 'gallery'),
61
59
  severity: 'error',
@@ -67,7 +65,7 @@ class GalleryToken extends index_1.Token {
67
65
  endCol: startCol + length,
68
66
  });
69
67
  }
70
- else if (child.type !== 'hidden' && child.type !== 'text') {
68
+ else if (child.type !== 'noinclude' && child.type !== 'text') {
71
69
  errors.push(...child.lint(start));
72
70
  }
73
71
  start += length + 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikilint",
3
- "version": "2.1.6",
3
+ "version": "2.2.0",
4
4
  "description": "A Node.js linter for MediaWiki markup",
5
5
  "keywords": [
6
6
  "mediawiki",