wikiparser-node 1.18.2 → 1.18.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.
- package/README.md +6 -1
- package/bundle/bundle-es7.min.js +29 -29
- package/bundle/bundle-lsp.min.js +30 -30
- package/bundle/bundle.min.js +26 -26
- package/config/minimum.json +7 -0
- package/dist/addon/token.js +10 -9
- package/dist/addon/transclude.js +1 -3
- package/dist/base.d.mts +4 -0
- package/dist/base.d.ts +4 -0
- package/dist/base.js +1 -0
- package/dist/base.mjs +2 -1
- package/dist/bin/config.js +3 -2
- package/dist/index.d.ts +5 -1
- package/dist/index.js +65 -72
- package/dist/lib/element.d.ts +6 -0
- package/dist/lib/element.js +543 -466
- package/dist/lib/lsp.d.ts +1 -0
- package/dist/lib/lsp.js +16 -10
- package/dist/lib/redirectMap.d.ts +7 -0
- package/dist/lib/redirectMap.js +31 -0
- package/dist/lib/text.d.ts +2 -2
- package/dist/lib/text.js +383 -325
- package/dist/lib/title.d.ts +23 -4
- package/dist/lib/title.js +17 -5
- package/dist/mixin/noEscape.d.ts +4 -0
- package/dist/mixin/noEscape.js +22 -0
- package/dist/mixin/readOnly.d.ts +4 -0
- package/dist/mixin/readOnly.js +26 -0
- package/dist/parser/braces.js +29 -15
- package/dist/parser/commentAndExt.js +5 -16
- package/dist/parser/links.js +1 -1
- package/dist/parser/quotes.js +1 -1
- package/dist/parser/redirect.js +1 -3
- package/dist/src/arg.js +253 -202
- package/dist/src/attribute.d.ts +0 -5
- package/dist/src/attribute.js +3 -7
- package/dist/src/converter.js +213 -162
- package/dist/src/gallery.js +1 -2
- package/dist/src/heading.js +5 -6
- package/dist/src/imageParameter.js +16 -16
- package/dist/src/imagemap.js +3 -2
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +722 -694
- package/dist/src/link/base.js +292 -241
- package/dist/src/link/file.js +13 -17
- package/dist/src/link/galleryImage.js +1 -1
- package/dist/src/link/redirectTarget.js +1 -2
- package/dist/src/magicLink.d.ts +0 -6
- package/dist/src/magicLink.js +5 -15
- package/dist/src/nested.js +7 -7
- package/dist/src/nowiki/base.js +2 -1
- package/dist/src/nowiki/index.js +4 -3
- package/dist/src/onlyinclude.js +95 -44
- package/dist/src/parameter.d.ts +0 -6
- package/dist/src/parameter.js +1 -13
- package/dist/src/redirect.js +6 -6
- package/dist/src/syntax.d.ts +4 -1
- package/dist/src/syntax.js +4 -1
- package/dist/src/table/base.d.ts +0 -5
- package/dist/src/table/base.js +2 -9
- package/dist/src/table/index.js +6 -3
- package/dist/src/table/td.d.ts +1 -0
- package/dist/src/table/td.js +2 -3
- package/dist/src/table/trBase.js +3 -1
- package/dist/src/tagPair/index.js +2 -1
- package/dist/src/transclude.js +705 -657
- package/dist/util/debug.js +10 -3
- package/dist/util/string.js +4 -5
- package/extensions/dist/base.js +8 -6
- package/extensions/dist/lint.js +1 -1
- package/extensions/es7/base.js +8 -6
- package/extensions/es7/lint.js +1 -1
- package/extensions/ui.css +1 -1
- package/package.json +3 -3
package/dist/lib/lsp.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export declare const isAttr: ({ type, parentNode, length, firstChild }: Token, s
|
|
|
20
20
|
/** VSCode-style language service */
|
|
21
21
|
export declare class LanguageService implements LanguageServiceBase {
|
|
22
22
|
#private;
|
|
23
|
+
/** @since v1.17.1 */
|
|
23
24
|
include: boolean;
|
|
24
25
|
lilypond: string;
|
|
25
26
|
/** @param uri 任务标识 */
|
package/dist/lib/lsp.js
CHANGED
|
@@ -26,6 +26,7 @@ const cssRules = {
|
|
|
26
26
|
'block-no-empty': null,
|
|
27
27
|
'property-no-unknown': null,
|
|
28
28
|
}, jsonSelector = document_1.jsonTags.map(s => `ext-inner#${s}`).join(), scores = new Map();
|
|
29
|
+
let colors;
|
|
29
30
|
/* NOT FOR BROWSER ONLY END */
|
|
30
31
|
exports.tasks = new WeakMap();
|
|
31
32
|
const refTags = new Set(['ref']), referencesTags = new Set(['ref', 'references']), nameAttrs = new Set(['name', 'extends', 'follow']), groupAttrs = new Set(['group']), renameTypes = new Set([
|
|
@@ -43,6 +44,8 @@ const refTags = new Set(['ref']), referencesTags = new Set(['ref', 'references']
|
|
|
43
44
|
'magic-word-name',
|
|
44
45
|
...renameTypes,
|
|
45
46
|
]), plainTypes = new Set(['text', 'comment', 'noinclude', 'include']), cssSelector = ['ext', 'html', 'table'].map(s => `${s}-attr#style`).join();
|
|
47
|
+
/^(?:http:\/\/|\/\/)/iu; // eslint-disable-line @typescript-eslint/no-unused-expressions
|
|
48
|
+
const getLinkRegex = (0, common_1.getRegex)(protocol => new RegExp(`^(?:${protocol}|//)`, 'iu'));
|
|
46
49
|
/**
|
|
47
50
|
* Check if a token is a plain attribute.
|
|
48
51
|
* @param token
|
|
@@ -276,6 +279,7 @@ class LanguageService {
|
|
|
276
279
|
#config;
|
|
277
280
|
#include;
|
|
278
281
|
#completionConfig;
|
|
282
|
+
/** @since v1.17.1 */
|
|
279
283
|
include = true;
|
|
280
284
|
/** @private */
|
|
281
285
|
config;
|
|
@@ -409,11 +413,14 @@ class LanguageService {
|
|
|
409
413
|
async provideDocumentColors(rgba, text, hsl = true) {
|
|
410
414
|
const root = await this.#queue(text);
|
|
411
415
|
/* NOT FOR BROWSER ONLY */
|
|
412
|
-
|
|
416
|
+
/* eslint-disable require-atomic-updates */
|
|
413
417
|
try {
|
|
414
|
-
colors
|
|
418
|
+
colors ??= new RegExp(String.raw `\b${Object.keys((await import('color-name')).default).join('|')}\b`, 'giu');
|
|
415
419
|
}
|
|
416
|
-
catch {
|
|
420
|
+
catch {
|
|
421
|
+
colors = false;
|
|
422
|
+
}
|
|
423
|
+
/* eslint-enable require-atomic-updates */
|
|
417
424
|
/* NOT FOR BROWSER ONLY END */
|
|
418
425
|
return root.querySelectorAll('attr-value,parameter-value,arg-default').reverse()
|
|
419
426
|
.flatMap(token => {
|
|
@@ -642,7 +649,7 @@ class LanguageService {
|
|
|
642
649
|
if (t === 'magic-word' && n !== 'invoke') {
|
|
643
650
|
return undefined;
|
|
644
651
|
}
|
|
645
|
-
const key = this.#text.slice(cur.getAbsoluteIndex(), root.indexFromPos(line, character)).trimStart(), [
|
|
652
|
+
const key = this.#text.slice(cur.getAbsoluteIndex(), root.indexFromPos(line, character)).trimStart(), [mod, func] = t === 'magic-word' ? transclusion.getModule() : [];
|
|
646
653
|
return key
|
|
647
654
|
? getCompletion(root.querySelectorAll('parameter').filter(token => {
|
|
648
655
|
if (token === parentNode
|
|
@@ -655,7 +662,7 @@ class LanguageService {
|
|
|
655
662
|
return true;
|
|
656
663
|
}
|
|
657
664
|
const [m, f] = token.parentNode.getModule();
|
|
658
|
-
return m ===
|
|
665
|
+
return m === mod && f === func;
|
|
659
666
|
}).map(({ name }) => name), 'Variable', key, position, type === 'parameter-value' ? '=' : '')
|
|
660
667
|
: undefined;
|
|
661
668
|
/* NOT FOR BROWSER ONLY */
|
|
@@ -898,8 +905,7 @@ class LanguageService {
|
|
|
898
905
|
*/
|
|
899
906
|
async provideLinks(text) {
|
|
900
907
|
this.config ??= index_1.default.getConfig();
|
|
901
|
-
|
|
902
|
-
const { articlePath, protocol } = this.config, absolute = articlePath?.includes('//'), protocolRegex = new RegExp(`^(?:${protocol}|//)`, 'iu');
|
|
908
|
+
const { articlePath, protocol } = this.config, absolute = articlePath?.includes('//'), protocolRegex = getLinkRegex(protocol);
|
|
903
909
|
return (await this.#queue(text))
|
|
904
910
|
.querySelectorAll(`magic-link,ext-link-url,free-ext-link,attr-value,image-parameter#link${absolute ? ',link-target,template-name,invoke-module,magic-word#filepath,magic-word#widget' : ''}`)
|
|
905
911
|
.reverse()
|
|
@@ -959,8 +965,8 @@ class LanguageService {
|
|
|
959
965
|
ns = name === 'filepath' ? 6 : 274;
|
|
960
966
|
// no default
|
|
961
967
|
}
|
|
962
|
-
const title = index_1.default
|
|
963
|
-
|
|
968
|
+
const title = index_1.default
|
|
969
|
+
.normalizeTitle(target, ns, false, this.config, { temporary: true });
|
|
964
970
|
if (!title.valid) {
|
|
965
971
|
return false;
|
|
966
972
|
}
|
|
@@ -1337,7 +1343,7 @@ class LanguageService {
|
|
|
1337
1343
|
this.config = index_1.default.getConfig(config);
|
|
1338
1344
|
}
|
|
1339
1345
|
catch {
|
|
1340
|
-
this.config = index_1.default.getConfig(await (0, config_1.default)(site, `${mt[0]}/w
|
|
1346
|
+
this.config = index_1.default.getConfig(await (0, config_1.default)(site, `${mt[0]}/w`, false, true));
|
|
1341
1347
|
}
|
|
1342
1348
|
Object.assign(this.config, { articlePath: `${mt[0]}/wiki/` });
|
|
1343
1349
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedirectMap = void 0;
|
|
4
|
+
const constants_1 = require("../util/constants");
|
|
5
|
+
/**
|
|
6
|
+
* 快速规范化页面标题
|
|
7
|
+
* @param title 标题
|
|
8
|
+
*/
|
|
9
|
+
const normalizeTitle = (title) => {
|
|
10
|
+
const Parser = require('../index');
|
|
11
|
+
return String(Parser.normalizeTitle(title, 0, false, undefined, { temporary: true }));
|
|
12
|
+
};
|
|
13
|
+
/** 重定向列表 */
|
|
14
|
+
class RedirectMap extends Map {
|
|
15
|
+
#redirect;
|
|
16
|
+
/** @ignore */
|
|
17
|
+
constructor(entries, redirect = true) {
|
|
18
|
+
super();
|
|
19
|
+
this.#redirect = redirect;
|
|
20
|
+
if (entries) {
|
|
21
|
+
for (const [k, v] of Symbol.iterator in entries ? entries : Object.entries(entries)) {
|
|
22
|
+
this.set(k, v);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
set(key, value) {
|
|
27
|
+
return super.set(normalizeTitle(key), this.#redirect ? normalizeTitle(value) : value);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.RedirectMap = RedirectMap;
|
|
31
|
+
constants_1.classes['RedirectMap'] = __filename;
|