wikilint 2.48.0 → 3.0.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 (75) hide show
  1. package/README.md +1 -1
  2. package/config/.schema.json +1 -1
  3. package/data/signatures.json +2 -2
  4. package/dist/base.d.mts +4 -3
  5. package/dist/base.d.ts +4 -3
  6. package/dist/base.js +1 -0
  7. package/dist/base.mjs +2 -1
  8. package/dist/bin/cli.js +2 -2
  9. package/dist/bin/config.js +1 -1
  10. package/dist/index.d.ts +0 -1
  11. package/dist/index.js +17 -11
  12. package/dist/internal.d.ts +1 -0
  13. package/dist/lib/document.d.ts +12 -12
  14. package/dist/lib/document.js +2 -4
  15. package/dist/lib/lintConfig.js +1 -0
  16. package/dist/lib/lsp.js +7 -4
  17. package/dist/lib/node.d.ts +0 -4
  18. package/dist/lib/node.js +9 -1
  19. package/dist/lib/text.js +1 -1
  20. package/dist/map.d.ts +2 -1
  21. package/dist/parser/commentAndExt.js +1 -2
  22. package/dist/parser/hrAndDoubleUnderscore.js +3 -2
  23. package/dist/parser/table.js +2 -1
  24. package/dist/src/arg.d.ts +1 -1
  25. package/dist/src/arg.js +1 -1
  26. package/dist/src/attribute.js +12 -12
  27. package/dist/src/attributes.d.ts +4 -3
  28. package/dist/src/converter.d.ts +1 -1
  29. package/dist/src/converter.js +1 -1
  30. package/dist/src/converterRule.d.ts +1 -1
  31. package/dist/src/converterRule.js +2 -2
  32. package/dist/src/extLink.d.ts +1 -1
  33. package/dist/src/extLink.js +1 -1
  34. package/dist/src/index.js +55 -14
  35. package/dist/src/link/base.js +2 -2
  36. package/dist/src/link/category.d.ts +1 -1
  37. package/dist/src/link/category.js +1 -1
  38. package/dist/src/link/index.d.ts +1 -1
  39. package/dist/src/link/index.js +1 -1
  40. package/dist/src/link/redirectTarget.d.ts +1 -1
  41. package/dist/src/link/redirectTarget.js +1 -1
  42. package/dist/src/magicLink.d.ts +4 -3
  43. package/dist/src/magicLink.js +1 -1
  44. package/dist/src/multiLine/gallery.d.ts +4 -4
  45. package/dist/src/multiLine/gallery.js +1 -1
  46. package/dist/src/multiLine/imagemap.d.ts +5 -3
  47. package/dist/src/multiLine/imagemap.js +1 -1
  48. package/dist/src/nested.d.ts +1 -1
  49. package/dist/src/nested.js +1 -1
  50. package/dist/src/nowiki/list.js +6 -3
  51. package/dist/src/nowiki/listBase.d.ts +24 -0
  52. package/dist/src/nowiki/listBase.js +104 -0
  53. package/dist/src/paramLine.d.ts +1 -1
  54. package/dist/src/paramLine.js +1 -1
  55. package/dist/src/pre.d.ts +5 -3
  56. package/dist/src/redirect.d.ts +1 -1
  57. package/dist/src/redirect.js +1 -1
  58. package/dist/src/singleLine/charinsertLine.d.ts +1 -1
  59. package/dist/src/singleLine/charinsertLine.js +1 -1
  60. package/dist/src/table/index.d.ts +2 -2
  61. package/dist/src/table/index.js +1 -1
  62. package/dist/src/table/tr.d.ts +1 -1
  63. package/dist/src/table/tr.js +1 -1
  64. package/dist/src/tag/index.d.ts +7 -5
  65. package/dist/src/tag/index.js +9 -4
  66. package/dist/src/tagPair/ext.js +1 -1
  67. package/dist/src/transclude.d.ts +1 -1
  68. package/dist/src/transclude.js +2 -2
  69. package/dist/util/ajv.js +26 -0
  70. package/dist/util/debug.js +7 -1
  71. package/dist/util/string.js +1 -0
  72. package/i18n/en.json +1 -0
  73. package/i18n/zh-hans.json +1 -0
  74. package/i18n/zh-hant.json +1 -0
  75. package/package.json +16 -16
package/README.md CHANGED
@@ -97,6 +97,6 @@ repos:
97
97
  # You can add any CLI options as needed
98
98
  entry: wikilint
99
99
  language: node
100
- additional_dependencies: ['wikilint@2.48.0']
100
+ additional_dependencies: ['wikilint@3.0.0']
101
101
  files: \.(mediawiki|wiki|wikitext)$
102
102
  ```
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "type": "object",
4
4
  "properties": {
5
5
  "ext": {
@@ -2658,13 +2658,13 @@
2658
2658
  "aliases": [
2659
2659
  "!"
2660
2660
  ],
2661
- "description": "Used to include a vertical bar (pipe).\n\nSee [help](https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#Escaping_pipe_characters_in_tables) for further explanation."
2661
+ "description": "Used to include an escaped [pipe](https://en.wikipedia.org/wiki/Vertical_bar) (`|`) character as part of template or parser function arguments to prevent interpretation as a parameter separator during expansion.\n\nSee [help](https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#Escaping_pipe_characters_in_tables) for further explanation."
2662
2662
  },
2663
2663
  {
2664
2664
  "aliases": [
2665
2665
  "="
2666
2666
  ],
2667
- "description": "Used to include an equal sign.\n\nSee [help](https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#Raw_equal_signs) for further explanation."
2667
+ "description": "Used to include an escaped equal sign (`=`) character as part of template or parser function arguments to prevent interpretation as a name-value separator during expansion.\n\nSee [help](https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#Raw_equal_signs) for further explanation."
2668
2668
  },
2669
2669
  {
2670
2670
  "aliases": [
package/dist/base.d.mts CHANGED
@@ -2,7 +2,7 @@ import type { Range, Position, ColorInformation, ColorPresentation, CompletionIt
2
2
  export interface Config {
3
3
  ext: string[];
4
4
  readonly html: [string[], string[], string[]];
5
- readonly namespaces: Record<string, string>;
5
+ readonly namespaces: Record<number, string>;
6
6
  readonly nsid: Record<string, number>;
7
7
  readonly parserFunction: [Record<string, string>, Record<string, string>, string[], string[]];
8
8
  readonly doubleUnderscore: [string[], string[], Record<string, string>, Record<string, string>];
@@ -15,7 +15,7 @@ export interface Config {
15
15
  articlePath?: string;
16
16
  }
17
17
  export type ConfigData = Omit<Config, 'excludes'>;
18
- export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'tvar' | 'tvar-name' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'param-line-key' | 'param-line-value' | 'imagemap-link' | 'charinsert-line';
18
+ export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'tvar' | 'tvar-name' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'param-line-key' | 'param-line-value' | 'imagemap-link' | 'charinsert-line' | 'list-range';
19
19
  export declare const stages: {
20
20
  redirect: number;
21
21
  onlyinclude: number;
@@ -41,8 +41,9 @@ export declare const stages: {
41
41
  list: number;
42
42
  dd: number;
43
43
  converter: number;
44
+ 'list-range': number;
44
45
  };
45
- export type Stage = keyof typeof stages;
46
+ declare type Stage = keyof typeof stages;
46
47
  export declare const rules: readonly ["arg-in-ext", "blank-alt", "bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "invalid-json", "invalid-ref", "invalid-url", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "required-attr", "syntax-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext", "invalid-css", "invalid-math"];
47
48
  export declare namespace LintError {
48
49
  type Severity = 'error' | 'warning';
package/dist/base.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { Range, Position, ColorInformation, ColorPresentation, CompletionIt
2
2
  export interface Config {
3
3
  ext: string[];
4
4
  readonly html: [string[], string[], string[]];
5
- readonly namespaces: Record<string, string>;
5
+ readonly namespaces: Record<number, string>;
6
6
  readonly nsid: Record<string, number>;
7
7
  readonly parserFunction: [Record<string, string>, Record<string, string>, string[], string[]];
8
8
  readonly doubleUnderscore: [string[], string[], Record<string, string>, Record<string, string>];
@@ -15,7 +15,7 @@ export interface Config {
15
15
  articlePath?: string;
16
16
  }
17
17
  export type ConfigData = Omit<Config, 'excludes'>;
18
- export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'tvar' | 'tvar-name' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'param-line-key' | 'param-line-value' | 'imagemap-link' | 'charinsert-line';
18
+ export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'tvar' | 'tvar-name' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'param-line-key' | 'param-line-value' | 'imagemap-link' | 'charinsert-line' | 'list-range';
19
19
  export declare const stages: {
20
20
  redirect: number;
21
21
  onlyinclude: number;
@@ -41,8 +41,9 @@ export declare const stages: {
41
41
  list: number;
42
42
  dd: number;
43
43
  converter: number;
44
+ 'list-range': number;
44
45
  };
45
- export type Stage = keyof typeof stages;
46
+ declare type Stage = keyof typeof stages;
46
47
  export declare const rules: readonly ["arg-in-ext", "blank-alt", "bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "invalid-json", "invalid-ref", "invalid-url", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "required-attr", "syntax-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext", "invalid-css", "invalid-math"];
47
48
  export declare namespace LintError {
48
49
  type Severity = 'error' | 'warning';
package/dist/base.js CHANGED
@@ -27,6 +27,7 @@ exports.stages = (() => {
27
27
  list: 10,
28
28
  dd: 10,
29
29
  converter: 11,
30
+ 'list-range': 12,
30
31
  };
31
32
  Object.setPrototypeOf(obj, null);
32
33
  return obj;
package/dist/base.mjs CHANGED
@@ -23,7 +23,8 @@ const stages = /* @__PURE__ */ (() => {
23
23
  "magic-link": 9,
24
24
  list: 10,
25
25
  dd: 10,
26
- converter: 11
26
+ converter: 11,
27
+ "list-range": 12
27
28
  };
28
29
  Object.setPrototypeOf(obj, null);
29
30
  return obj;
package/dist/bin/cli.js CHANGED
@@ -404,9 +404,9 @@ const { mtimeMs } = fs_1.default.statSync(config), obj = cache?.[include ? 'incl
404
404
  exiting ||= Boolean(nLocalErr || strict && nLocalWarn);
405
405
  }
406
406
  if (nErr || nWarn) {
407
- console.error(styleText(['red', 'bold'], '%s'), `\n✖ ${plural(nErr + nWarn, 'problem')} (${plural(nErr, 'error')}, ${plural(nWarn, 'warning')})`);
407
+ console.error(styleText(['red', 'bold'], '\n✖ %s (%s, %s)'), plural(nErr + nWarn, 'problem'), plural(nErr, 'error'), plural(nWarn, 'warning'));
408
408
  if (nFixableErr || nFixableWarn) {
409
- console.error(styleText(['red', 'bold'], '%s'), ` ${plural(nFixableErr, 'error')} and ${plural(nFixableWarn, 'warning')} potentially fixable with the \`--fix\` option.`);
409
+ console.error(styleText(['red', 'bold'], ' %s and %s potentially fixable with the `--fix` option.'), plural(nFixableErr, 'error'), plural(nFixableWarn, 'warning'));
410
410
  }
411
411
  console.error();
412
412
  }
@@ -41,7 +41,7 @@ const filterGadget = (id) => {
41
41
  const n = Number(id);
42
42
  return n < 2300 || n > 2303; // Gadget, Gadget talk, Gadget definition, Gadget definition talk
43
43
  };
44
- const pkg = 'wikilint', version = '2.48.0';
44
+ const pkg = 'wikilint', version = '3.0.0';
45
45
  /**
46
46
  * Get the parser configuration for a Wikimedia Foundation project.
47
47
  * @param site site nickname
package/dist/index.d.ts CHANGED
@@ -52,7 +52,6 @@ declare interface Parser extends ParserBase {
52
52
  declare const Parser: Parser;
53
53
  // @ts-expect-error mixed export styles
54
54
  export = Parser;
55
- export default Parser;
56
55
  export type { Config, ConfigData, LintConfig, LintError, TokenTypes, LanguageService, QuickFixData, Title, };
57
56
  export type * from './internal';
58
57
  declare global { type WikiParserAcceptable = Record<string, any>; }
package/dist/index.js CHANGED
@@ -189,13 +189,11 @@ const Parser = {
189
189
  config = configOrStage;
190
190
  page = pageOrConfig;
191
191
  }
192
- maxStage ??= constants_1.MAX_STAGE;
192
+ maxStage ??= constants_1.MAX_STAGE + 1;
193
193
  config ??= this.getConfig();
194
- // eslint-disable-next-line unicorn/prefer-smaller-scope
195
- let types;
196
194
  LSP: if (typeof maxStage !== 'number') {
197
- types = Array.isArray(maxStage) ? maxStage : [maxStage];
198
- maxStage = Math.max(...types.map(t => base_1.stages[t] || constants_1.MAX_STAGE));
195
+ const types = Array.isArray(maxStage) ? maxStage : [maxStage];
196
+ maxStage = Math.max(...types.map(t => base_1.stages[t] || constants_1.MAX_STAGE + 1));
199
197
  }
200
198
  const { Token } = require('./src/index');
201
199
  const root = debug_1.Shadow.run(() => {
@@ -203,20 +201,29 @@ const Parser = {
203
201
  token.type = 'root';
204
202
  token.pageName = page;
205
203
  try {
206
- return token.parse(maxStage, include);
204
+ token.parse(maxStage, include);
205
+ PRINT: if (maxStage > constants_1.MAX_STAGE) {
206
+ token.buildLists();
207
+ }
208
+ return token;
207
209
  /* NOT FOR BROWSER ONLY */
208
210
  }
209
211
  catch (e) /* c8 ignore start */ {
210
212
  if (e instanceof Error) {
211
- const file = path_1.default.join(__dirname, '..', 'errors', new Date().toISOString()), stage = token.getAttribute('stage');
213
+ const file = path_1.default.join(__dirname, '..', 'errors', new Date().toISOString()), stage = token.getAttribute('stage'), isMax = stage === constants_1.MAX_STAGE;
212
214
  for (const k in config) {
213
215
  if (k.startsWith('regex') || config[k] instanceof Set) {
214
216
  delete config[k];
215
217
  }
216
218
  }
217
- fs_1.default.writeFileSync(file, stage === constants_1.MAX_STAGE ? wikitext : token.toString());
219
+ fs_1.default.writeFileSync(file, isMax ? wikitext : token.toString());
218
220
  fs_1.default.writeFileSync(`${file}.err`, e.stack);
219
- fs_1.default.writeFileSync(`${file}.json`, JSON.stringify({ stage, include, config, page }, null, '\t'));
221
+ fs_1.default.writeFileSync(`${file}.json`, JSON.stringify({
222
+ stage: isMax ? maxStage : stage,
223
+ include,
224
+ config,
225
+ page,
226
+ }, null, '\t'));
220
227
  }
221
228
  throw e;
222
229
  }
@@ -240,7 +247,7 @@ const Parser = {
240
247
  lint(wikitext, includeOrPage, configOrInclude, pageOrConfig) {
241
248
  LINT: {
242
249
  const [include, config, page] = getParams(includeOrPage, configOrInclude, pageOrConfig);
243
- return debug_1.Shadow.internal(() => this.parse(wikitext, include, undefined, config, page).lint(), this);
250
+ return debug_1.Shadow.internal(() => this.parse(wikitext, include, constants_1.MAX_STAGE, config, page).lint(), this);
244
251
  }
245
252
  },
246
253
  /* NOT FOR BROWSER ONLY */
@@ -278,5 +285,4 @@ for (const key in Parser) {
278
285
  }
279
286
  }
280
287
  Object.defineProperties(Parser, def);
281
- exports.default = Parser;
282
288
  module.exports = Parser;
@@ -55,3 +55,4 @@ export type { CommentLineToken } from './src/nowiki/commentLine';
55
55
  export type { TranslateToken } from './src/tagPair/translate';
56
56
  export type { TvarToken } from './src/tag/tvar';
57
57
  export type { FuncTagToken } from './src/funcTag';
58
+ export type { ListRangeToken } from './src/nowiki/listBase';
@@ -1,8 +1,8 @@
1
1
  import type { Position } from 'vscode-languageserver-types';
2
2
  import type { TextDocument, Range } from 'vscode-languageserver-textdocument';
3
- import type { JSONDocument, LanguageService as JSONLanguageService } from 'vscode-json-languageservice';
4
- import type { Stylesheet, LanguageService as CSSLanguageService } from 'vscode-css-languageservice';
5
- import type { IHTMLDataProvider } from 'vscode-html-languageservice';
3
+ import type * as JsonLanguageService from 'vscode-json-languageservice';
4
+ import type * as CssLanguageService from 'vscode-css-languageservice';
5
+ import type * as HtmlLanguageService from 'vscode-html-languageservice';
6
6
  import type { PublicApi } from 'stylelint';
7
7
  import type { Token } from '../internal';
8
8
  export interface TexvcLocation {
@@ -32,9 +32,9 @@ declare interface Texvcjs {
32
32
  }): TexvcReport;
33
33
  }
34
34
  export declare const loadTexvcjs: () => Texvcjs | null;
35
- export declare const loadJsonLSP: () => JSONLanguageService | null;
36
- export declare const loadCssLSP: () => CSSLanguageService | null;
37
- export declare const loadHtmlData: () => IHTMLDataProvider | null;
35
+ export declare const loadJsonLSP: () => JsonLanguageService.LanguageService | null;
36
+ export declare const loadCssLSP: () => CssLanguageService.LanguageService | null;
37
+ export declare const loadHtmlData: () => HtmlLanguageService.IHTMLDataProvider | null;
38
38
  export declare const loadStylelint: () => PublicApi | null;
39
39
  /** embedded document */
40
40
  declare abstract class EmbeddedDocument implements TextDocument {
@@ -65,9 +65,9 @@ declare abstract class EmbeddedDocument implements TextDocument {
65
65
  }
66
66
  /** embedded JSON document */
67
67
  export declare class EmbeddedJSONDocument extends EmbeddedDocument {
68
- jsonDoc: JSONDocument;
69
- abstract getLineRange(): Range;
70
- abstract getEOLCharacters(): string;
68
+ jsonDoc: JsonLanguageService.JSONDocument;
69
+ getLineRange: () => Range;
70
+ getEOLCharacters: () => string;
71
71
  /**
72
72
  * @param root root token
73
73
  * @param token current token
@@ -76,9 +76,9 @@ export declare class EmbeddedJSONDocument extends EmbeddedDocument {
76
76
  }
77
77
  /** embedded CSS document */
78
78
  export declare class EmbeddedCSSDocument extends EmbeddedDocument {
79
- styleSheet: Stylesheet;
80
- abstract getLineRange(): Range;
81
- abstract getEOLCharacters(): string;
79
+ styleSheet: CssLanguageService.Stylesheet;
80
+ getLineRange: () => Range;
81
+ getEOLCharacters: () => string;
82
82
  /**
83
83
  * @param root root token
84
84
  * @param token current token
@@ -27,8 +27,7 @@ let jsonLSP;
27
27
  const loadJsonLSP = () => {
28
28
  if (jsonLSP === undefined) {
29
29
  try {
30
- jsonLSP = require('vscode-json-languageservice')
31
- .getLanguageService({
30
+ jsonLSP = require('vscode-json-languageservice').getLanguageService({
32
31
  /* c8 ignore start */
33
32
  /** @implements */
34
33
  async schemaRequestService(uri) {
@@ -67,8 +66,7 @@ let cssLSP;
67
66
  const loadCssLSP = () => {
68
67
  if (cssLSP === undefined) {
69
68
  try {
70
- cssLSP = require('vscode-css-languageservice')
71
- .getCSSLanguageService();
69
+ cssLSP = require('vscode-css-languageservice').getCSSLanguageService();
72
70
  }
73
71
  catch /* c8 ignore start */ {
74
72
  cssLSP = null;
@@ -123,6 +123,7 @@ const defaultLintRuleConfig = {
123
123
  // imageParameter: 2,
124
124
  // parameter: 2,
125
125
  unknownImageParameter: 1,
126
+ // indicator: 2,
126
127
  // dynamicpagelist: 2,
127
128
  // inputbox: 2,
128
129
  // seo: 2,
package/dist/lib/lsp.js CHANGED
@@ -339,6 +339,9 @@ function getStylelintPos(rect, bottom, lineOrCode, columnOrOffset) {
339
339
  * @param errors LilyPond errors
340
340
  */
341
341
  const getLilyPondDiagnostics = (root, token, errors) => {
342
+ if (!errors) {
343
+ return [];
344
+ }
342
345
  const { top, left } = root.posFromIndex(token.lastChild.getAbsoluteIndex());
343
346
  return errors.map(({ line, col, message }) => {
344
347
  const pos = (0, lint_1.getEndPos)(top, left, line, col);
@@ -952,7 +955,7 @@ class LanguageService {
952
955
  try {
953
956
  // eslint-disable-next-line @typescript-eslint/strict-void-return
954
957
  await util_1.default.promisify(child_process_1.execFile)(this.lilypond, ['-dno-print-pages', '-s', '-o', dir, file]);
955
- scores.set(score, []);
958
+ scores.set(score, undefined);
956
959
  }
957
960
  catch (e) {
958
961
  const { stderr } = e;
@@ -1393,7 +1396,7 @@ class LanguageService {
1393
1396
  contents: {
1394
1397
  kind: 'markdown',
1395
1398
  value: (info.signatures
1396
- ? `${info.signatures.map(params => `- **{{ ${f}${params.length === 0 ? '**' : `${colon}** `}${params.map(({ label, const: c }) => c ? label : `*${label}*`).join(' **|** ')} **}}**`).join('\n')}\n\n`
1399
+ ? `${info.signatures.map(params => `- **{{ ${f}${params.length === 0 ? '**' : `${colon}** `}${params.map(({ label, const: c }) => c ? label : `*${label}*`).join(' **|** ')} **}}**\n`).join('')}\n`
1397
1400
  : '')
1398
1401
  + info.description,
1399
1402
  },
@@ -1537,7 +1540,7 @@ class LanguageService {
1537
1540
  * @param diagnostics grammar diagnostics / 语法诊断信息
1538
1541
  */
1539
1542
  provideCodeAction(diagnostics) {
1540
- const actionable = diagnostics.filter((diagnostic) => diagnostic.data), fixable = actionable.filter(({ source, data }) => source === 'WikiLint' && data.some(({ fix }) => fix)), fixableRules = [...new Set(fixable.map(({ code }) => code))];
1543
+ const actionable = diagnostics.filter((diagnostic) => diagnostic.data), fixable = actionable.filter(({ source, data }) => source === 'WikiLint' && data.some(({ fix }) => fix));
1541
1544
  return [
1542
1545
  ...actionable.flatMap(diagnostic => diagnostic.data.map((data) => ({
1543
1546
  title: data.title,
@@ -1551,7 +1554,7 @@ class LanguageService {
1551
1554
  ...fixable.length === 0
1552
1555
  ? []
1553
1556
  : [
1554
- ...fixableRules.map((rule) => ({
1557
+ ...[...new Set(fixable.map(({ code }) => code))].map((rule) => ({
1555
1558
  title: `Fix all: ${rule}`,
1556
1559
  kind: 'source.fixAll',
1557
1560
  diagnostics: fixable.filter(({ code }) => code === rule),
@@ -11,10 +11,6 @@ export interface Position {
11
11
  readonly top: number;
12
12
  readonly left: number;
13
13
  }
14
- export interface CaretPosition {
15
- readonly offsetNode: AstNodes;
16
- readonly offset: number;
17
- }
18
14
  export interface Font {
19
15
  bold: boolean;
20
16
  italic: boolean;
package/dist/lib/node.js CHANGED
@@ -90,7 +90,7 @@ let AstNode = (() => {
90
90
  /** @private */
91
91
  getChildNodes() {
92
92
  const { childNodes } = this;
93
- if (Object.isFrozen(childNodes)) { // NOT FOR TEMPLATE
93
+ if (Object.isFrozen(childNodes)) { // eslint-disable-line unicorn/prefer-ternary
94
94
  return [...childNodes];
95
95
  }
96
96
  return childNodes;
@@ -250,6 +250,14 @@ let AstNode = (() => {
250
250
  getLines() {
251
251
  LINT: return (0, common_1.splitLines)(String(this));
252
252
  }
253
+ /** @private */
254
+ removeInternal() {
255
+ PRINT: {
256
+ const { parentNode } = this, i = parentNode?.childNodes.indexOf(this);
257
+ parentNode?.removeAt(i);
258
+ return i;
259
+ }
260
+ }
253
261
  };
254
262
  return AstNode = _classThis;
255
263
  })();
package/dist/lib/text.js CHANGED
@@ -70,7 +70,7 @@ class AstText extends node_1.AstNode {
70
70
  }
71
71
  /** @private */
72
72
  toString(skip) {
73
- if (skip && !this.parentNode?.getAttribute('built')) { // NOT FOR TEMPLATE
73
+ if (skip && !this.parentNode?.getAttribute('built')) { // eslint-disable-line unicorn/prefer-ternary
74
74
  return (0, string_1.removeComment)(this.data);
75
75
  }
76
76
  return this.data;
package/dist/map.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { RedirectToken, RedirectTargetToken, OnlyincludeToken, IncludeToken, CommentToken, ExtToken, AttributesToken, AttributeToken, AtomToken, ArgToken, TranscludeToken, SyntaxToken, ParameterToken, HeadingToken, HtmlToken, TableToken, TrToken, TdToken, DoubleUnderscoreToken, HrToken, LinkToken, CategoryToken, FileToken, ImageParameterToken, QuoteToken, ExtLinkToken, MagicLinkToken, ListToken, DdToken, ConverterToken, ConverterFlagsToken, ConverterRuleToken, TranslateToken, TvarToken, HiddenToken, GalleryImageToken, ParamLineToken, ImagemapLinkToken, CharinsertLineToken } from './internal';
1
+ import type { RedirectToken, RedirectTargetToken, OnlyincludeToken, IncludeToken, CommentToken, ExtToken, AttributesToken, AttributeToken, AtomToken, ArgToken, TranscludeToken, SyntaxToken, ParameterToken, HeadingToken, HtmlToken, TableToken, TrToken, TdToken, DoubleUnderscoreToken, HrToken, LinkToken, CategoryToken, FileToken, ImageParameterToken, QuoteToken, ExtLinkToken, MagicLinkToken, ListToken, DdToken, ConverterToken, ConverterFlagsToken, ConverterRuleToken, TranslateToken, TvarToken, HiddenToken, GalleryImageToken, ParamLineToken, ImagemapLinkToken, CharinsertLineToken, ListRangeToken } from './internal';
2
2
  export interface TokenTypeMap {
3
3
  redirect: RedirectToken;
4
4
  'redirect-syntax': SyntaxToken;
@@ -64,5 +64,6 @@ export interface TokenTypeMap {
64
64
  'param-line-value': AtomToken;
65
65
  'imagemap-link': ImagemapLinkToken;
66
66
  'charinsert-line': CharinsertLineToken;
67
+ 'list-range': ListRangeToken;
67
68
  }
68
69
  export type SelectedTokenTypes = keyof TokenTypeMap;
@@ -10,8 +10,7 @@ const ext_1 = require("../src/tagPair/ext");
10
10
  const comment_1 = require("../src/nowiki/comment");
11
11
  const onlyincludeLeft = '<onlyinclude>', onlyincludeRight = '</onlyinclude>', { length } = onlyincludeLeft, getExtRegex = [false, true].map(includeOnly => {
12
12
  const noincludeRegex = includeOnly ? 'includeonly' : '(?:no|only)include', includeRegex = includeOnly ? 'noinclude' : 'includeonly';
13
- return (0, common_1.getRegex)(exts => new RegExp(String.raw `<!--.*?(?:-->|$)|<${noincludeRegex}(?:\s[^>]*)?/?>|</${noincludeRegex}\s*>|<(${exts // eslint-disable-next-line unicorn/prefer-string-raw
14
- })(\s[^>]*?)?(?:/>|>(.*?)</(${'\\1'}\s*)>)|<(${includeRegex})(\s[^>]*?)?(?:/>|>(.*?)(?:</(${includeRegex}\s*)>|$))`, 'gisu'));
13
+ return (0, common_1.getRegex)(exts => new RegExp(String.raw `<!--.*?(?:-->|$)|<${noincludeRegex}(?:\s[^>]*)?/?>|</${noincludeRegex}\s*>|<(${exts})(\s[^>]*?)?(?:/>|>(.*?)</(${'\\1'}\s*)>)|<(${includeRegex})(\s[^>]*?)?(?:/>|>(.*?)(?:</(${includeRegex}\s*)>|$))`, 'gisu'));
15
14
  });
16
15
  /**
17
16
  * 更新`<onlyinclude>`和`</onlyinclude>`的位置
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseHrAndDoubleUnderscore = void 0;
4
4
  const cm_util_1 = require("@bhsd/cm-util");
5
+ const debug_1 = require("../util/debug");
5
6
  const hr_1 = require("../src/nowiki/hr");
6
7
  const doubleUnderscore_1 = require("../src/nowiki/doubleUnderscore");
7
8
  const heading_1 = require("../src/heading");
@@ -16,7 +17,7 @@ const parseHrAndDoubleUnderscore = ({ firstChild: { data }, type, name }, config
16
17
  config.insensitiveDoubleUnderscore ??= new Set(insensitive.filter(cm_util_1.isUnderscore));
17
18
  config.sensitiveDoubleUnderscore ??= new Set(sensitive.filter(cm_util_1.isUnderscore));
18
19
  config.regexHrAndDoubleUnderscore ??= new RegExp(String.raw `^((?:\0\d+[cno]\x7F)*)(-{4,})|__(${all.filter(cm_util_1.isUnderscore).join('|')})__|_{2}(${all.filter(s => !(0, cm_util_1.isUnderscore)(s)).map(s => s.slice(2, -2)).join('|')})_{2}`, 'gimu');
19
- if (type !== 'root' && (type !== 'ext-inner' || name !== 'poem')) {
20
+ if (type !== 'root' && (type !== 'ext-inner' || !(0, debug_1.isIsolated)(name))) {
20
21
  data = `\0${data}`;
21
22
  }
22
23
  data = data.replace(config.regexHrAndDoubleUnderscore, (m, p1, p2, p3, p4) => {
@@ -41,6 +42,6 @@ const parseHrAndDoubleUnderscore = ({ firstChild: { data }, type, name }, config
41
42
  return text;
42
43
  });
43
44
  }
44
- return type === 'root' || type === 'ext-inner' && name === 'poem' ? data : data.slice(1);
45
+ return type === 'root' || type === 'ext-inner' && (0, debug_1.isIsolated)(name) ? data : data.slice(1);
45
46
  };
46
47
  exports.parseHrAndDoubleUnderscore = parseHrAndDoubleUnderscore;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseTable = void 0;
4
+ const debug_1 = require("../util/debug");
4
5
  const index_1 = require("../src/index");
5
6
  const index_2 = require("../src/table/index");
6
7
  const tr_1 = require("../src/table/tr");
@@ -25,7 +26,7 @@ const pop = (top, stack) => top.is('td') ? stack.pop() : top;
25
26
  */
26
27
  const parseTable = ({ firstChild: { data }, type, name }, config, accum) => {
27
28
  const stack = [], lines = data.split('\n');
28
- let out = type === 'root' || type === 'parameter-value' || type === 'ext-inner' && name === 'poem'
29
+ let out = type === 'root' || type === 'parameter-value' || type === 'ext-inner' && (0, debug_1.isIsolated)(name)
29
30
  ? ''
30
31
  : `\n${lines.shift()}`, top;
31
32
  /**
package/dist/src/arg.d.ts CHANGED
@@ -6,7 +6,7 @@ import type { Config, LintError } from '../base';
6
6
  * argument wrapped in `{{{}}}`
7
7
  *
8
8
  * `{{{}}}`包裹的参数
9
- * @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken[]]}`
9
+ * @classdesc `{childNodes: [AtomToken] | [AtomToken, Token, ...HiddenToken[]]}`
10
10
  */
11
11
  export declare abstract class ArgToken extends Token {
12
12
  #private;
package/dist/src/arg.js CHANGED
@@ -51,7 +51,7 @@ const hidden_1 = require("./hidden");
51
51
  * argument wrapped in `{{{}}}`
52
52
  *
53
53
  * `{{{}}}`包裹的参数
54
- * @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken[]]}`
54
+ * @classdesc `{childNodes: [AtomToken] | [AtomToken, Token, ...HiddenToken[]]}`
55
55
  */
56
56
  let ArgToken = (() => {
57
57
  let _classDecorators = [noEscape_1.noEscape, (0, padded_1.padded)('{{{'), (0, gapped_1.gapped)()];
@@ -178,19 +178,19 @@ class AttributeToken extends index_2.Token {
178
178
  }
179
179
  }
180
180
  }
181
- else if ((/^xmlns:[\w:.-]+$/u.test(name) || urlAttrs.has(name)) && evil.test(value)
182
- || simple
183
- && (name === 'href' || type === 'ext-attr' && tag === 'img' && name === 'src')
184
- && !new RegExp(String.raw `^(?:${this.getAttribute('config').protocol}|//)\S+$`, 'iu')
185
- .test(value)) {
186
- LINT: {
187
- const s = lintConfig.getSeverity(rule, 'value');
188
- return s && (0, lint_1.generateForChild)(lastChild, rect, rule, 'illegal-attribute-value', s);
181
+ else {
182
+ let valueIssue = (/^xmlns:[\w:.-]+$/u.test(name) || urlAttrs.has(name)) && evil.test(value)
183
+ || simple
184
+ && (name === 'href' || type === 'ext-attr' && tag === 'img' && name === 'src')
185
+ && !new RegExp(String.raw `^(?:${this.getAttribute('config').protocol}|//)\S+$`, 'iu')
186
+ .test(value);
187
+ if (simple && !valueIssue && type !== 'ext-attr') {
188
+ const data = (0, lint_1.provideValues)(tag, name), v = value.toLowerCase();
189
+ if (data.length > 0 && data.every(n => n !== v)) {
190
+ valueIssue = true;
191
+ }
189
192
  }
190
- }
191
- else if (simple && type !== 'ext-attr') {
192
- const data = (0, lint_1.provideValues)(tag, name), v = value.toLowerCase();
193
- if (data.length > 0 && data.every(n => n !== v)) {
193
+ if (valueIssue) {
194
194
  LINT: {
195
195
  const s = lintConfig.getSeverity(rule, 'value');
196
196
  return s && (0, lint_1.generateForChild)(lastChild, rect, rule, 'illegal-attribute-value', s);
@@ -7,6 +7,7 @@ import type { ExtToken, HtmlToken, SyntaxToken } from '../internal';
7
7
  import type { AttributeTypes } from './attribute';
8
8
  import type { TableTokens } from './table/index';
9
9
  declare type AttributesTypes = `${AttributeTypes}s`;
10
+ declare type Child = AtomToken | AttributeToken;
10
11
  /**
11
12
  * 将属性类型转换为单属性类型
12
13
  * @param type 属性类型
@@ -21,9 +22,9 @@ export declare const toAttributeType: (type: AttributesTypes) => AttributeTypes;
21
22
  export declare abstract class AttributesToken extends Token {
22
23
  #private;
23
24
  readonly name: string;
24
- readonly childNodes: readonly (AtomToken | AttributeToken)[];
25
- abstract get firstChild(): AtomToken | AttributeToken | undefined;
26
- abstract get lastChild(): AtomToken | AttributeToken | undefined;
25
+ readonly childNodes: readonly Child[];
26
+ abstract get firstChild(): Child | undefined;
27
+ abstract get lastChild(): Child | undefined;
27
28
  abstract get parentNode(): ExtToken | HtmlToken | TableTokens | undefined;
28
29
  abstract get previousSibling(): SyntaxToken | undefined;
29
30
  get type(): AttributesTypes;
@@ -6,7 +6,7 @@ import type { Config } from '../base';
6
6
  * language conversion
7
7
  *
8
8
  * 转换
9
- * @classdesc `{childNodes: [ConverterFlagsToken, ...ConverterRuleToken[]]}`
9
+ * @classdesc `{childNodes: [ConverterFlagsToken, ConverterRuleToken, ...ConverterRuleToken[]]}`
10
10
  */
11
11
  export declare abstract class ConverterToken extends Token {
12
12
  readonly childNodes: readonly [ConverterFlagsToken, ConverterRuleToken, ...ConverterRuleToken[]];
@@ -45,7 +45,7 @@ const converterRule_1 = require("./converterRule");
45
45
  * language conversion
46
46
  *
47
47
  * 转换
48
- * @classdesc `{childNodes: [ConverterFlagsToken, ...ConverterRuleToken[]]}`
48
+ * @classdesc `{childNodes: [ConverterFlagsToken, ConverterRuleToken, ...ConverterRuleToken[]]}`
49
49
  */
50
50
  let ConverterToken = (() => {
51
51
  let _classDecorators = [noEscape_1.noEscape, (0, padded_1.padded)('-{')];
@@ -6,7 +6,7 @@ import type { ConverterToken, ConverterFlagsToken } from '../internal';
6
6
  * language conversion rule
7
7
  *
8
8
  * 转换规则
9
- * @classdesc `{childNodes: [Token?, AtomToken?, Token]}`
9
+ * @classdesc `{childNodes: [Token] | [Token?, AtomToken, Token]}`
10
10
  */
11
11
  export declare abstract class ConverterRuleToken extends Token {
12
12
  readonly childNodes: readonly [Token] | readonly [AtomToken, Token] | readonly [Token, AtomToken, Token];
@@ -60,7 +60,7 @@ const getRuleFromTo = (text, type, config, accum) => {
60
60
  * language conversion rule
61
61
  *
62
62
  * 转换规则
63
- * @classdesc `{childNodes: [Token?, AtomToken?, Token]}`
63
+ * @classdesc `{childNodes: [Token] | [Token?, AtomToken, Token]}`
64
64
  */
65
65
  let ConverterRuleToken = (() => {
66
66
  let _classDecorators = [noEscape_1.noEscape];
@@ -86,7 +86,7 @@ let ConverterRuleToken = (() => {
86
86
  */
87
87
  constructor(rule, hasColon = true, config = index_1.default.getConfig(), accum = []) {
88
88
  super(undefined, config, accum, {});
89
- const i = rule.indexOf(':'), j = rule.slice(0, i).indexOf('=>'), v = j === -1 ? rule.slice(0, i) : rule.slice(j + 2, i);
89
+ const i = rule.indexOf(':'), j = rule.slice(0, i).indexOf('=>'), v = rule.slice(j === -1 ? 0 : j + 2, i);
90
90
  if (hasColon && config.variants.includes(v.trim())) {
91
91
  super.insertAt(new atom_1.AtomToken(v, 'converter-rule-variant', config, accum));
92
92
  super.insertAt(getRuleFromTo(rule.slice(i + 1), 'to', config, accum));
@@ -5,7 +5,7 @@ import type { Config, LintError } from '../base';
5
5
  * external link
6
6
  *
7
7
  * 外链
8
- * @classdesc `{childNodes: [MagicLinkToken, ?Token]}`
8
+ * @classdesc `{childNodes: [MagicLinkToken, Token?]}`
9
9
  */
10
10
  export declare abstract class ExtLinkToken extends Token {
11
11
  #private;
@@ -48,7 +48,7 @@ const magicLink_1 = require("./magicLink");
48
48
  * external link
49
49
  *
50
50
  * 外链
51
- * @classdesc `{childNodes: [MagicLinkToken, ?Token]}`
51
+ * @classdesc `{childNodes: [MagicLinkToken, Token?]}`
52
52
  */
53
53
  let ExtLinkToken = (() => {
54
54
  let _classDecorators = [(0, padded_1.padded)('[')];