wikilint 2.28.0 → 2.29.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 (58) hide show
  1. package/config/default.json +15 -16
  2. package/config/jawiki.json +15 -16
  3. package/data/ext/ThirdPartyNotices.txt +33 -0
  4. package/data/ext/mapframe.json +489 -2
  5. package/dist/base.d.mts +4 -2
  6. package/dist/base.d.ts +4 -2
  7. package/dist/base.js +2 -0
  8. package/dist/base.mjs +3 -1
  9. package/dist/bin/config.js +11 -11
  10. package/dist/index.d.ts +2 -1
  11. package/dist/index.js +23 -2
  12. package/dist/lib/document.d.ts +23 -7
  13. package/dist/lib/document.js +7 -27
  14. package/dist/lib/element.js +1 -1
  15. package/dist/lib/lintConfig.js +4 -0
  16. package/dist/lib/lsp.d.ts +1 -12
  17. package/dist/lib/lsp.js +45 -76
  18. package/dist/lib/node.js +23 -20
  19. package/dist/lib/title.d.ts +3 -1
  20. package/dist/lib/title.js +37 -9
  21. package/dist/mixin/elementLike.js +14 -9
  22. package/dist/parser/commentAndExt.js +34 -27
  23. package/dist/parser/hrAndDoubleUnderscore.js +8 -7
  24. package/dist/parser/links.js +4 -3
  25. package/dist/parser/redirect.js +1 -1
  26. package/dist/parser/selector.js +6 -8
  27. package/dist/src/arg.js +4 -5
  28. package/dist/src/attribute.js +28 -0
  29. package/dist/src/attributes.js +1 -1
  30. package/dist/src/converter.js +6 -3
  31. package/dist/src/imageParameter.d.ts +3 -1
  32. package/dist/src/imageParameter.js +65 -11
  33. package/dist/src/index.d.ts +8 -0
  34. package/dist/src/index.js +21 -28
  35. package/dist/src/link/file.js +8 -11
  36. package/dist/src/link/galleryImage.js +1 -1
  37. package/dist/src/link/redirectTarget.js +1 -1
  38. package/dist/src/magicLink.js +12 -1
  39. package/dist/src/multiLine/gallery.js +2 -2
  40. package/dist/src/multiLine/imagemap.js +3 -4
  41. package/dist/src/multiLine/paramTag.js +2 -2
  42. package/dist/src/nowiki/doubleUnderscore.d.ts +3 -1
  43. package/dist/src/nowiki/doubleUnderscore.js +6 -2
  44. package/dist/src/nowiki/index.js +59 -2
  45. package/dist/src/table/base.js +1 -2
  46. package/dist/src/table/index.js +1 -2
  47. package/dist/src/tagPair/ext.js +10 -3
  48. package/dist/src/transclude.js +3 -3
  49. package/dist/util/constants.js +3 -1
  50. package/dist/util/debug.js +1 -1
  51. package/dist/util/search.js +16 -0
  52. package/dist/util/sharable.js +27 -3
  53. package/dist/util/sharable.mjs +28 -4
  54. package/i18n/en.json +4 -0
  55. package/i18n/zh-hans.json +4 -0
  56. package/i18n/zh-hant.json +4 -0
  57. package/package.json +8 -6
  58. package/data/ext/maplink.json +0 -4
@@ -14,7 +14,7 @@ const frame = new Map([
14
14
  ['frameless', 'Frameless'],
15
15
  ['framed', 'Frame'],
16
16
  ['thumbnail', 'Thumb'],
17
- ]), argTypes = new Set(['arg']), transclusion = new Set(['template', 'magic-word']), horizAlign = new Set(['left', 'right', 'center', 'none']), vertAlign = new Set(['baseline', 'sub', 'super', 'top', 'text-top', 'middle', 'bottom', 'text-bottom']), extensions = new Set(['tiff', 'tif', 'png', 'gif', 'jpg', 'jpeg', 'webp', 'xcf', 'pdf', 'svg', 'djvu']);
17
+ ]), argTypes = new Set(['arg']), transclusion = new Set(['template', 'magic-word']), horizAlign = new Set(['left', 'right', 'center', 'none']), vertAlign = new Set(['baseline', 'sub', 'super', 'top', 'text-top', 'middle', 'bottom', 'text-bottom']);
18
18
  /**
19
19
  * a more sophisticated string-explode function
20
20
  * @param str string to be exploded
@@ -44,10 +44,7 @@ const explode = (str) => {
44
44
  * @param args image parameter tokens
45
45
  * @param types token types to be filtered
46
46
  */
47
- const filterArgs = (args, types) => args.filter(({ childNodes }) => {
48
- const visibleNodes = childNodes.filter(node => node.text().trim());
49
- return visibleNodes.length !== 1 || !types.has(visibleNodes[0].type);
50
- });
47
+ const filterArgs = (args, types) => args.filter(({ childNodes }) => !childNodes.some(node => node.text().trim() && types.has(node.type)));
51
48
  /**
52
49
  * image
53
50
  *
@@ -85,7 +82,7 @@ class FileToken extends base_1.LinkBaseToken {
85
82
  const errors = super.lint(start, re), args = filterArgs(this.getAllArgs(), argTypes), keys = [...new Set(args.map(({ name }) => name))], frameKeys = keys.filter(key => frame.has(key)), horizAlignKeys = keys.filter(key => horizAlign.has(key)), vertAlignKeys = keys.filter(key => vertAlign.has(key)), [fr] = frameKeys, unscaled = fr === 'framed' || fr === 'manualthumb', rect = new rect_1.BoundingRect(this, start), { lintConfig } = index_1.default, { computeEditInfo, fix } = lintConfig, { ns, extension, } = this.getAttribute('title'), { firstChild } = this;
86
83
  let rule = 'nested-link', s = lintConfig.getSeverity(rule, 'file');
87
84
  if (s
88
- && extensions.has(extension)
85
+ && imageParameter_1.extensions.has(extension)
89
86
  && this.closest('ext-link-text')
90
87
  && this.getValue('link')?.trim() !== '') {
91
88
  const e = (0, lint_1.generateForSelf)(this, rect, rule, 'link-in-extlink', s);
@@ -160,22 +157,22 @@ class FileToken extends base_1.LinkBaseToken {
160
157
  ];
161
158
  }
162
159
  if (relevantArgs.length > 1) {
163
- let severity = !isCaption || !extension || extensions.has(extension);
160
+ let severity = !isCaption || !extension || imageParameter_1.extensions.has(extension);
164
161
  if (isCaption && severity) {
165
162
  const plainArgs = filterArgs(relevantArgs, transclusion);
166
163
  severity = plainArgs.length > 1 && ((arg) => plainArgs.includes(arg));
167
164
  }
168
- errors.push(...generate(relevantArgs, 'duplicate', key, severity));
165
+ Array.prototype.push.apply(errors, generate(relevantArgs, 'duplicate', key, severity));
169
166
  }
170
167
  }
171
168
  if (frameKeys.length > 1) {
172
- errors.push(...generate(args.filter(({ name }) => frame.has(name)), 'conflicting', 'frame'));
169
+ Array.prototype.push.apply(errors, generate(args.filter(({ name }) => frame.has(name)), 'conflicting', 'frame'));
173
170
  }
174
171
  if (horizAlignKeys.length > 1) {
175
- errors.push(...generate(args.filter(({ name }) => horizAlign.has(name)), 'conflicting', 'horizontal-alignment'));
172
+ Array.prototype.push.apply(errors, generate(args.filter(({ name }) => horizAlign.has(name)), 'conflicting', 'horizontal-alignment'));
176
173
  }
177
174
  if (vertAlignKeys.length > 1) {
178
- errors.push(...generate(args.filter(({ name }) => vertAlign.has(name)), 'conflicting', 'vertical-alignment'));
175
+ Array.prototype.push.apply(errors, generate(args.filter(({ name }) => vertAlign.has(name)), 'conflicting', 'vertical-alignment'));
179
176
  }
180
177
  return errors;
181
178
  }
@@ -91,7 +91,7 @@ let GalleryImageToken = (() => {
91
91
  /** @private */
92
92
  getTitle(temporary) {
93
93
  const imagemap = this.type === 'imagemap-image';
94
- return this.normalizeTitle(this.firstChild.toString(), imagemap ? 0 : 6, { halfParsed: true, temporary, decode: !imagemap });
94
+ return this.normalizeTitle(this.firstChild.toString(), imagemap ? 0 : 6, { halfParsed: true, temporary, decode: !imagemap, page: '' });
95
95
  }
96
96
  /** 判定无效的图片 */
97
97
  #lint() {
@@ -31,7 +31,7 @@ class RedirectTargetToken extends base_1.LinkBaseToken {
31
31
  }
32
32
  /** @private */
33
33
  getTitle() {
34
- return this.normalizeTitle(this.firstChild.toString(), 0, { halfParsed: true, decode: true });
34
+ return this.normalizeTitle(this.firstChild.toString(), 0, { halfParsed: true, decode: true, page: '' });
35
35
  }
36
36
  /** @private */
37
37
  lint(start = this.getAbsoluteIndex()) {
@@ -84,7 +84,18 @@ class MagicLinkToken extends index_2.Token {
84
84
  }
85
85
  return errors;
86
86
  }
87
- const pipe = type === 'ext-link-url', rule = 'unterminated-url', severity = lintConfig.getSeverity(rule, pipe ? 'pipe' : 'punctuation');
87
+ let rule = 'invalid-url', severity = lintConfig.getSeverity(rule);
88
+ if (severity && !this.querySelector('magic-word')) {
89
+ try {
90
+ this.getUrl();
91
+ }
92
+ catch {
93
+ errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'invalid-url', severity));
94
+ }
95
+ }
96
+ const pipe = type === 'ext-link-url';
97
+ rule = 'unterminated-url';
98
+ severity = lintConfig.getSeverity(rule, pipe ? 'pipe' : 'punctuation');
88
99
  if (severity) {
89
100
  const regex = pipe ? /\|/u : /[,;。:!?()]+/u, child = childNodes.find((c) => c.type === 'text' && regex.test(c.data));
90
101
  if (child) {
@@ -42,7 +42,7 @@ class GalleryToken extends index_2.MultiLineToken {
42
42
  * @param file 文件名
43
43
  */
44
44
  #checkFile(file) {
45
- return this.normalizeTitle(file, 6, { halfParsed: true, temporary: true, decode: true }).valid;
45
+ return this.normalizeTitle(file, 6, { halfParsed: true, temporary: true, decode: true, page: '' }).valid;
46
46
  }
47
47
  /** @private */
48
48
  lint(start = this.getAbsoluteIndex(), re) {
@@ -83,7 +83,7 @@ class GalleryToken extends index_2.MultiLineToken {
83
83
  else if (type !== 'noinclude' && type !== 'text') {
84
84
  const childErrors = child.lint(start, re);
85
85
  if (childErrors.length > 0) {
86
- errors.push(...childErrors);
86
+ Array.prototype.push.apply(errors, childErrors);
87
87
  }
88
88
  }
89
89
  start += length + 1;
@@ -35,7 +35,7 @@ class ImagemapToken extends index_2.MultiLineToken {
35
35
  //
36
36
  }
37
37
  else if (first) {
38
- const pipe = line.indexOf('|'), file = pipe === -1 ? line : line.slice(0, pipe), { valid, ns, } = this.normalizeTitle(file, 0, { halfParsed: true, temporary: true });
38
+ const pipe = line.indexOf('|'), file = pipe === -1 ? line : line.slice(0, pipe), { valid, ns, } = this.normalizeTitle(file, 0, { halfParsed: true, temporary: true, page: '' });
39
39
  if (valid
40
40
  && ns === 6) {
41
41
  // @ts-expect-error abstract class
@@ -56,8 +56,7 @@ class ImagemapToken extends index_2.MultiLineToken {
56
56
  const i = line.indexOf('['), substr = line.slice(i), mtIn = /^\[\[([^|]+)(?:\|([^\]]*))?\]\][\w\s]*$/u
57
57
  .exec(substr);
58
58
  if (mtIn) {
59
- if (this.normalizeTitle(mtIn[1], 0, { halfParsed: true, temporary: true, selfLink: true })
60
- .valid) {
59
+ if (this.normalizeTitle(mtIn[1], 0, { halfParsed: true, temporary: true, selfLink: true, page: '' }).valid) {
61
60
  // @ts-expect-error abstract class
62
61
  super.insertAt(new imagemapLink_1.ImagemapLinkToken(line.slice(0, i), mtIn.slice(1), substr.slice(substr.indexOf(']]') + 2), config, accum));
63
62
  continue;
@@ -85,7 +84,7 @@ class ImagemapToken extends index_2.MultiLineToken {
85
84
  const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start), { childNodes, image } = this, rule = 'invalid-imagemap', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, image ? 'link' : 'image');
86
85
  if (s) {
87
86
  if (image) {
88
- errors.push(...childNodes.filter(child => {
87
+ Array.prototype.push.apply(errors, childNodes.filter(child => {
89
88
  const str = child.toString().trim();
90
89
  return child.is('noinclude')
91
90
  && str && !str.startsWith('#');
@@ -19,7 +19,7 @@ class ParamTagToken extends index_2.MultiLineToken {
19
19
  constructor(include, wikitext, config = index_1.default.getConfig(), accum = [], acceptable) {
20
20
  super(undefined, config, accum, {});
21
21
  if (wikitext) {
22
- this.append(...wikitext.split('\n')
22
+ this.safeAppend(wikitext.split('\n')
23
23
  .map(line => acceptable ? line : (0, commentAndExt_1.parseCommentAndExt)(line, config, accum, include))
24
24
  // @ts-expect-error abstract class
25
25
  .map((line) => new paramLine_1.ParamLineToken(line, config, accum, {})));
@@ -54,7 +54,7 @@ class ParamTagToken extends index_2.MultiLineToken {
54
54
  else {
55
55
  const childErrors = child.lint(start, false);
56
56
  if (childErrors.length > 0) {
57
- errors.push(...childErrors);
57
+ Array.prototype.push.apply(errors, childErrors);
58
58
  }
59
59
  }
60
60
  }
@@ -7,11 +7,13 @@ import type { Token } from '../../internal';
7
7
  * 状态开关
8
8
  */
9
9
  export declare abstract class DoubleUnderscoreToken extends NowikiBaseToken {
10
+ #private;
10
11
  readonly name: string;
11
12
  get type(): 'double-underscore';
12
13
  /**
13
14
  * @param word 状态开关名
14
15
  * @param sensitive 是否固定大小写
16
+ * @param fullWidth 是否为全角下划线
15
17
  */
16
- constructor(word: string, sensitive: boolean, config: Config, accum?: Token[]);
18
+ constructor(word: string, sensitive: boolean, fullWidth: boolean, config: Config, accum?: Token[]);
17
19
  }
@@ -58,21 +58,25 @@ let DoubleUnderscoreToken = (() => {
58
58
  if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
59
59
  __runInitializers(_classThis, _classExtraInitializers);
60
60
  }
61
+ #fullWidth;
61
62
  get type() {
62
63
  return 'double-underscore';
63
64
  }
64
65
  /**
65
66
  * @param word 状态开关名
66
67
  * @param sensitive 是否固定大小写
68
+ * @param fullWidth 是否为全角下划线
67
69
  */
68
- constructor(word, sensitive, config, accum) {
70
+ constructor(word, sensitive, fullWidth, config, accum) {
69
71
  super(word, config, accum);
70
72
  const lc = word.toLowerCase(), { doubleUnderscore: [, , iAlias, sAlias] } = config;
71
73
  this.setAttribute('name', (sensitive ? sAlias?.[word]?.toLowerCase() : iAlias?.[lc]) ?? lc);
74
+ this.#fullWidth = fullWidth;
72
75
  }
73
76
  /** @private */
74
77
  toString() {
75
- return `__${this.innerText}__`;
78
+ const underscore = this.#fullWidth ? '__' : '__';
79
+ return underscore + this.innerText + underscore;
76
80
  }
77
81
  };
78
82
  return DoubleUnderscoreToken = _classThis;
@@ -8,6 +8,21 @@ const common_1 = require("@bhsd/common");
8
8
  const lint_1 = require("../../util/lint");
9
9
  const index_1 = __importDefault(require("../../index"));
10
10
  const base_1 = require("./base");
11
+ /* NOT FOR BROWSER ONLY */
12
+ const constants_1 = require("../../util/constants");
13
+ const document_1 = require("../../lib/document");
14
+ /** @ignore */
15
+ const updateLocation = ({ startIndex, startLine, startCol, endIndex, endLine, endCol }, { offset, line, column }, n) => {
16
+ const index = startIndex + offset - n;
17
+ if (index < startIndex) {
18
+ return [startIndex, startLine, startCol];
19
+ }
20
+ else if (index > endIndex) {
21
+ return [endIndex, endLine, endCol];
22
+ }
23
+ return [index, startLine + line - 1, (line === 1 ? startCol - n : 0) + column - 1];
24
+ };
25
+ /* NOT FOR BROWSER ONLY END */
11
26
  const getLintRegex = /* #__PURE__ */ (0, common_1.getRegex)(name => new RegExp(String.raw `<\s*(?:/\s*)${name === 'nowiki' ? '' : '?'}(${name})\b`, 'giu'));
12
27
  const voidExt = new Set(['languages', 'section', 'templatestyles']);
13
28
  /**
@@ -27,7 +42,10 @@ class NowikiToken extends base_1.NowikiBaseToken {
27
42
  /** @private */
28
43
  lint(start = this.getAbsoluteIndex()) {
29
44
  LINT: { // eslint-disable-line no-unused-labels
30
- const { name } = this, rule = 'void-ext', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, name);
45
+ const { name,
46
+ /* NOT FOR BROWSER ONLY */
47
+ innerText, previousSibling, } = this, { lintConfig } = index_1.default;
48
+ let rule = 'void-ext', s = lintConfig.getSeverity(rule, name);
31
49
  if (s && this.#lint()) {
32
50
  const e = (0, lint_1.generateForSelf)(this, { start }, rule, index_1.default.msg('nothing-in', name), s);
33
51
  if (lintConfig.computeEditInfo) {
@@ -35,7 +53,46 @@ class NowikiToken extends base_1.NowikiBaseToken {
35
53
  }
36
54
  return [e];
37
55
  }
38
- return super.lint(start, getLintRegex(name));
56
+ const errors = super.lint(start, getLintRegex(name));
57
+ /* NOT FOR BROWSER ONLY */
58
+ rule = 'invalid-math';
59
+ s = lintConfig.getSeverity(rule);
60
+ if (s && document_1.texvcjs && constants_1.mathTags.has(name)) {
61
+ const isChem = name !== 'math', display = previousSibling?.getAttr('display') ?? 'block';
62
+ let tex = innerText, n = 0;
63
+ if (isChem) {
64
+ tex = String.raw `\ce{${tex}}`;
65
+ n = 4;
66
+ }
67
+ switch (display) {
68
+ case 'block':
69
+ tex = String.raw `{\displaystyle ${tex}}`;
70
+ n += 15;
71
+ break;
72
+ case 'inline':
73
+ tex = String.raw `{\textstyle ${tex}}`;
74
+ n += 12;
75
+ break;
76
+ case 'linebreak':
77
+ tex = String.raw `\[ ${tex} \]`;
78
+ n += 3;
79
+ // no default
80
+ }
81
+ const result = document_1.texvcjs.check(tex, {
82
+ usemhchem: isChem || Boolean(previousSibling?.hasAttr('chem')),
83
+ });
84
+ if (result.status !== '+') {
85
+ const e = (0, lint_1.generateForSelf)(this, { start }, rule, 'chem-required', s);
86
+ if (result.status !== 'C') {
87
+ const { error: { message, location } } = result, [endIndex, endLine, endCol] = updateLocation(e, location.end, n);
88
+ [e.startIndex, e.startLine, e.startCol] = updateLocation(e, location.start, n);
89
+ Object.assign(e, { endIndex, endLine, endCol, message });
90
+ }
91
+ errors.push(e);
92
+ }
93
+ }
94
+ /* NOT FOR BROWSER ONLY END */
95
+ return errors;
39
96
  }
40
97
  }
41
98
  }
@@ -51,8 +51,7 @@ const escapeTable = (syntax) => {
51
51
  const wikitext = syntax.childNodes.map(child => child.type === 'text'
52
52
  ? child.data.replace(/\|\|/gu, '{{!!}}')
53
53
  .replace(/\|/gu, '{{!}}')
54
- : child.toString()).join(''), { childNodes } = index_1.default
55
- .parse(wikitext, syntax.getAttribute('include'), 2, syntax.getAttribute('config'));
54
+ : child.toString()).join(''), { childNodes } = index_1.default.parseWithRef(wikitext, syntax, 2);
56
55
  syntax.safeReplaceChildren(childNodes);
57
56
  };
58
57
  /**
@@ -140,9 +140,8 @@ let TableToken = (() => {
140
140
  * @param syntax syntax of the table end / 表格结尾语法
141
141
  */
142
142
  close(syntax = '\n|}', halfParsed) {
143
- const config = this.getAttribute('config'), accum = this.getAttribute('accum');
144
143
  debug_1.Shadow.run(() => {
145
- const token = new syntax_1.SyntaxToken(halfParsed ? syntax : undefined, 'table-syntax', config, accum);
144
+ const token = new syntax_1.SyntaxToken(halfParsed ? syntax : undefined, 'table-syntax', this.getAttribute('config'), this.getAttribute('accum'));
146
145
  super.insertAt(token);
147
146
  });
148
147
  }
@@ -193,9 +193,16 @@ let ExtToken = (() => {
193
193
  errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'ext-in-html', severity));
194
194
  }
195
195
  }
196
- const rule = 'var-anchor', s = lintConfig.getSeverity(rule, 'ref');
197
- if (s && this.name === 'ref' && this.closest('heading-title')) {
198
- errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'variable-anchor', s));
196
+ if (this.name === 'ref') {
197
+ let rule = 'var-anchor', s = lintConfig.getSeverity(rule, 'ref');
198
+ if (s && this.closest('heading-title')) {
199
+ errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'variable-anchor', s));
200
+ }
201
+ rule = 'nested-link';
202
+ s = lintConfig.getSeverity(rule, 'ref');
203
+ if (s && this.closest('link,ext-link-text')) {
204
+ errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'ref-in-link', s));
205
+ }
199
206
  }
200
207
  return errors;
201
208
  }
@@ -219,7 +219,7 @@ let TranscludeToken = (() => {
219
219
  }
220
220
  /** 获取模板或模块名 */
221
221
  #getTitle() {
222
- const isTemplate = this.type === 'template', title = this.normalizeTitle(this.childNodes[isTemplate ? 0 : 1].text(), isTemplate ? 10 : 828, { temporary: true });
222
+ const isTemplate = this.type === 'template', title = this.normalizeTitle((isTemplate ? '' : 'Module:') + this.childNodes[isTemplate ? 0 : 1].text(), 10, { temporary: true, ...!isTemplate && { page: '' } });
223
223
  return title;
224
224
  }
225
225
  /** @private */
@@ -310,7 +310,7 @@ let TranscludeToken = (() => {
310
310
  const duplicatedArgs = this.getDuplicatedArgs()
311
311
  .filter(([, parameter]) => !parameter[0].querySelector('ext')), msg = 'duplicate-parameter';
312
312
  for (const [, args] of duplicatedArgs) {
313
- errors.push(...args.map(arg => {
313
+ Array.prototype.push.apply(errors, args.map(arg => {
314
314
  const e = (0, lint_1.generateForChild)(arg, rect, rule, msg, s);
315
315
  if (computeEditInfo) {
316
316
  e.suggestions = [(0, lint_1.fixByRemove)(e, -1)];
@@ -442,7 +442,7 @@ let TranscludeToken = (() => {
442
442
  else {
443
443
  try {
444
444
  const possibleValues = first.getPossibleValues();
445
- queue.splice(i, 1, ...possibleValues);
445
+ Array.prototype.splice.apply(queue, [i, 1, ...possibleValues]);
446
446
  i += possibleValues.length;
447
447
  }
448
448
  catch {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.enMsg = exports.BuildMethod = exports.MAX_STAGE = void 0;
3
+ exports.mathTags = exports.enMsg = exports.BuildMethod = exports.MAX_STAGE = void 0;
4
4
  exports.MAX_STAGE = 11;
5
5
  var BuildMethod;
6
6
  (function (BuildMethod) {
@@ -9,3 +9,5 @@ var BuildMethod;
9
9
  })(BuildMethod || (exports.BuildMethod = BuildMethod = {}));
10
10
  // eslint-disable-next-line n/no-missing-require
11
11
  exports.enMsg = (() => require('../../i18n/en.json'))();
12
+ /* NOT FOR BROWSER ONLY */
13
+ exports.mathTags = new Set(['math', 'chem', 'ce']);
@@ -43,7 +43,7 @@ const setChildNodes = (parent, position, deleteCount, inserted = []) => {
43
43
  nodes = inserted;
44
44
  }
45
45
  else {
46
- removed = nodes.splice(position, deleteCount, ...inserted);
46
+ removed = Array.prototype.splice.apply(nodes, [position, deleteCount, ...inserted]);
47
47
  }
48
48
  for (let i = 0; i < inserted.length; i++) {
49
49
  const node = inserted[i];
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const binary_search_1 = __importDefault(require("binary-search"));
7
+ /**
8
+ * 二分法查找索引
9
+ * @param haystack 数组
10
+ * @param needle 目标值
11
+ * @param comparator 比较函数
12
+ */
13
+ exports.default = (haystack, needle, comparator) => {
14
+ const found = (0, binary_search_1.default)(haystack, needle, comparator);
15
+ return found < 0 ? ~found : found; // eslint-disable-line no-bitwise
16
+ };
@@ -15,6 +15,17 @@ const blockAttrs = new Set(['align']), citeAttrs = new Set(['cite']), citeAndAtt
15
15
  'copy',
16
16
  'highlight',
17
17
  'start',
18
+ ]), weightAttrs = new Set(['weight']), mapAttrs = new Set([
19
+ 'width',
20
+ 'height',
21
+ 'zoom',
22
+ 'latitude',
23
+ 'longitude',
24
+ 'align',
25
+ 'mapstyle',
26
+ 'lang',
27
+ 'alt',
28
+ 'text',
18
29
  ]), empty = new Set();
19
30
  exports.commonHtmlAttrs = new Set([
20
31
  'id',
@@ -100,14 +111,13 @@ exports.commonHtmlAttrs = new Set([
100
111
  references: new Set(['group', 'responsive']),
101
112
  charinsert: new Set(['label']),
102
113
  choose: new Set(['uncached', 'before', 'after']),
103
- option: new Set(['weight']),
114
+ option: weightAttrs,
115
+ choicetemplate: weightAttrs,
104
116
  imagemap: empty,
105
117
  inputbox: empty,
106
118
  templatestyles: new Set(['src', 'wrapper']),
107
119
  dynamicpagelist: empty,
108
120
  poll: new Set(['id', 'show-results-before-voting']),
109
- sm2: typeAttrs,
110
- flashmp3: typeAttrs,
111
121
  score: new Set([
112
122
  'line_width_inches',
113
123
  'lang',
@@ -170,6 +180,20 @@ exports.commonHtmlAttrs = new Set([
170
180
  timeline: new Set(['method', 'font']),
171
181
  quiz: new Set(['display', 'shuffleanswers', 'points', 'shuffle', 'case']),
172
182
  languages: empty,
183
+ mapframe: new Set([...mapAttrs, 'frameless']),
184
+ maplink: new Set([...mapAttrs, 'class']),
185
+ rss: new Set([
186
+ 'template',
187
+ 'templatename',
188
+ 'max',
189
+ 'highlight',
190
+ 'filter',
191
+ 'filterout',
192
+ 'reverse',
193
+ 'date',
194
+ 'item-max-length',
195
+ ]),
196
+ 'page-collection': new Set(['lang', 'name', 'description', 'end-date']),
173
197
  }))(), exports.obsoleteAttrs = (() => ({
174
198
  table: obsoleteTableAttrs,
175
199
  td: new Set([...obsoleteTdAttrs, 'scope']),
@@ -13,6 +13,17 @@ const blockAttrs = /* @__PURE__ */ new Set(["align"]), citeAttrs = /* @__PURE__
13
13
  "copy",
14
14
  "highlight",
15
15
  "start"
16
+ ]), weightAttrs = /* @__PURE__ */ new Set(["weight"]), mapAttrs = /* @__PURE__ */ new Set([
17
+ "width",
18
+ "height",
19
+ "zoom",
20
+ "latitude",
21
+ "longitude",
22
+ "align",
23
+ "mapstyle",
24
+ "lang",
25
+ "alt",
26
+ "text"
16
27
  ]), empty = /* @__PURE__ */ new Set();
17
28
  const commonHtmlAttrs = /* @__PURE__ */ new Set([
18
29
  "id",
@@ -98,14 +109,13 @@ const commonHtmlAttrs = /* @__PURE__ */ new Set([
98
109
  references: /* @__PURE__ */ new Set(["group", "responsive"]),
99
110
  charinsert: /* @__PURE__ */ new Set(["label"]),
100
111
  choose: /* @__PURE__ */ new Set(["uncached", "before", "after"]),
101
- option: /* @__PURE__ */ new Set(["weight"]),
112
+ option: weightAttrs,
113
+ choicetemplate: weightAttrs,
102
114
  imagemap: empty,
103
115
  inputbox: empty,
104
116
  templatestyles: /* @__PURE__ */ new Set(["src", "wrapper"]),
105
117
  dynamicpagelist: empty,
106
118
  poll: /* @__PURE__ */ new Set(["id", "show-results-before-voting"]),
107
- sm2: typeAttrs,
108
- flashmp3: typeAttrs,
109
119
  score: /* @__PURE__ */ new Set([
110
120
  "line_width_inches",
111
121
  "lang",
@@ -167,7 +177,21 @@ const commonHtmlAttrs = /* @__PURE__ */ new Set([
167
177
  templatedata: empty,
168
178
  timeline: /* @__PURE__ */ new Set(["method", "font"]),
169
179
  quiz: /* @__PURE__ */ new Set(["display", "shuffleanswers", "points", "shuffle", "case"]),
170
- languages: empty
180
+ languages: empty,
181
+ mapframe: /* @__PURE__ */ new Set([...mapAttrs, "frameless"]),
182
+ maplink: /* @__PURE__ */ new Set([...mapAttrs, "class"]),
183
+ rss: /* @__PURE__ */ new Set([
184
+ "template",
185
+ "templatename",
186
+ "max",
187
+ "highlight",
188
+ "filter",
189
+ "filterout",
190
+ "reverse",
191
+ "date",
192
+ "item-max-length"
193
+ ]),
194
+ "page-collection": /* @__PURE__ */ new Set(["lang", "name", "description", "end-date"])
171
195
  }))(), obsoleteAttrs = /* @__PURE__ */ (() => ({
172
196
  table: obsoleteTableAttrs,
173
197
  td: /* @__PURE__ */ new Set([...obsoleteTdAttrs, "scope"]),
package/i18n/en.json CHANGED
@@ -2,6 +2,7 @@
2
2
  "attributes-of-closing-tag": "attributes of a closing tag",
3
3
  "bold-apostrophes": "bold apostrophes",
4
4
  "bold-in-header": "bold text in a section header",
5
+ "chem-required": "chem attribute required",
5
6
  "close": null,
6
7
  "closing-and-self-closing": "tag that is both closing and self-closing",
7
8
  "comment": null,
@@ -39,6 +40,8 @@
39
40
  "invalid-isbn": "invalid ISBN",
40
41
  "invalid-parameter": "invalid parameter of <$1>",
41
42
  "invalid-self-closing": "invalid self-closing tag",
43
+ "invalid-thumb": "invalid thumbnail filename",
44
+ "invalid-url": "invalid URL",
42
45
  "invisible-triple-braces": "invisible content inside triple braces",
43
46
  "italic-apostrophes": "italic apostrophes",
44
47
  "left-bracket": "opening bracket",
@@ -56,6 +59,7 @@
56
59
  "prefix": null,
57
60
  "pipe-in-link": "additional \"|\" in the link text",
58
61
  "pipe-in-table": "additional \"|\" in a table cell",
62
+ "ref-in-link": "<ref> in an internal or external link",
59
63
  "remove": null,
60
64
  "template-in-link": "template in an internal link target",
61
65
  "unbalanced-in-section-header": "unbalanced $1 in a section header",
package/i18n/zh-hans.json CHANGED
@@ -2,6 +2,7 @@
2
2
  "attributes-of-closing-tag": "闭合标签的属性",
3
3
  "bold-apostrophes": "粗体单引号",
4
4
  "bold-in-header": "章节标题中的粗体文本",
5
+ "chem-required": "需要chem属性",
5
6
  "close": "闭合",
6
7
  "closing-and-self-closing": "同时闭合和自封闭的标签",
7
8
  "comment": "注释",
@@ -39,6 +40,8 @@
39
40
  "invalid-isbn": "无效的ISBN",
40
41
  "invalid-parameter": "<$1>的无效参数",
41
42
  "invalid-self-closing": "无效自封闭标签",
43
+ "invalid-thumb": "无效的缩略图文件名",
44
+ "invalid-url": "无效的URL",
42
45
  "invisible-triple-braces": "三重括号内的不可见部分",
43
46
  "italic-apostrophes": "斜体单引号",
44
47
  "left-bracket": "左括号",
@@ -56,6 +59,7 @@
56
59
  "prefix": "前缀",
57
60
  "pipe-in-link": "链接文本中多余的\"|\"",
58
61
  "pipe-in-table": "表格单元格中多余的\"|\"",
62
+ "ref-in-link": "内链或外链中的<ref>",
59
63
  "remove": "移除",
60
64
  "template-in-link": "内链目标包含模板",
61
65
  "unbalanced-in-section-header": "章节标题中未成对的$1",
package/i18n/zh-hant.json CHANGED
@@ -2,6 +2,7 @@
2
2
  "attributes-of-closing-tag": "結束標籤的屬性",
3
3
  "bold-apostrophes": "粗體撇號",
4
4
  "bold-in-header": "章節標題中的粗體文本",
5
+ "chem-required": "需要chem屬性",
5
6
  "close": "閉合",
6
7
  "closing-and-self-closing": "同時閉合和自封閉的標籤",
7
8
  "comment": "註解",
@@ -39,6 +40,8 @@
39
40
  "invalid-isbn": "無效的ISBN",
40
41
  "invalid-parameter": "<$1>的無效參數",
41
42
  "invalid-self-closing": "無效自封閉標籤",
43
+ "invalid-thumb": "無效的縮略圖檔名",
44
+ "invalid-url": "無效的URL",
42
45
  "invisible-triple-braces": "三重括號內的不可見部分",
43
46
  "italic-apostrophes": "斜體撇號",
44
47
  "left-bracket": "左括號",
@@ -56,6 +59,7 @@
56
59
  "prefix": "前綴",
57
60
  "pipe-in-link": "連結文本中多餘的\"|\"",
58
61
  "pipe-in-table": "表格儲存格中多餘的\"|\"",
62
+ "ref-in-link": "內部或外部連結裡的<ref>",
59
63
  "remove": "移除",
60
64
  "template-in-link": "內部連結目標包含模板",
61
65
  "unbalanced-in-section-header": "章節標題裡未成對的$1",