wikiparser-node 1.31.0 → 1.33.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.
- package/README.md +5 -0
- package/bundle/bundle-es8.min.js +28 -29
- package/bundle/bundle-lsp.min.js +31 -31
- package/bundle/bundle.min.js +24 -24
- package/coverage/badge.svg +1 -1
- package/dist/addon/attribute.js +186 -0
- package/dist/addon/link.js +91 -0
- package/dist/addon/table.js +150 -105
- package/dist/addon/token.js +8 -304
- package/dist/addon/transclude.js +9 -6
- package/dist/base.d.mts +9 -1
- package/dist/base.d.ts +9 -1
- package/dist/bin/config.js +1 -1
- package/dist/index.d.ts +24 -5
- package/dist/index.js +71 -92
- package/dist/internal.d.ts +4 -0
- package/dist/lib/document.d.ts +9 -7
- package/dist/lib/document.js +91 -66
- package/dist/lib/element.d.ts +7 -7
- package/dist/lib/element.js +48 -50
- package/dist/lib/lintConfig.js +3 -1
- package/dist/lib/lsp.js +127 -56
- package/dist/lib/node.js +20 -14
- package/dist/lib/text.js +6 -6
- package/dist/lib/title.d.ts +11 -0
- package/dist/lib/title.js +37 -13
- package/dist/mixin/elementLike.js +2 -3
- package/dist/mixin/syntax.js +13 -7
- package/dist/parser/commentAndExt.js +3 -3
- package/dist/parser/selector.js +16 -41
- package/dist/render/expand.js +216 -0
- package/dist/render/extension.js +141 -0
- package/dist/render/html.js +91 -0
- package/dist/{addon → render}/magicWords.js +48 -7
- package/dist/render/syntaxhighlight.js +415 -0
- package/dist/src/arg.js +1 -1
- package/dist/src/attribute.d.ts +9 -5
- package/dist/src/attribute.js +68 -108
- package/dist/src/attributes.d.ts +7 -1
- package/dist/src/attributes.js +22 -51
- package/dist/src/converter.js +4 -2
- package/dist/src/converterFlags.js +8 -6
- package/dist/src/converterRule.js +19 -15
- package/dist/src/extLink.js +1 -1
- package/dist/src/heading.d.ts +1 -1
- package/dist/src/heading.js +5 -3
- package/dist/src/imageParameter.d.ts +7 -4
- package/dist/src/imageParameter.js +47 -28
- package/dist/src/index.d.ts +13 -5
- package/dist/src/index.js +67 -42
- package/dist/src/link/base.d.ts +1 -1
- package/dist/src/link/base.js +26 -38
- package/dist/src/link/category.d.ts +7 -0
- package/dist/src/link/category.js +101 -37
- package/dist/src/link/categorytree.d.ts +27 -0
- package/dist/src/link/categorytree.js +115 -0
- package/dist/src/link/file.d.ts +3 -2
- package/dist/src/link/file.js +23 -9
- package/dist/src/link/galleryImage.js +7 -9
- package/dist/src/link/index.d.ts +1 -1
- package/dist/src/link/index.js +10 -31
- package/dist/src/multiLine/gallery.d.ts +1 -4
- package/dist/src/multiLine/gallery.js +1 -11
- package/dist/src/multiLine/imagemap.d.ts +0 -1
- package/dist/src/multiLine/imagemap.js +98 -152
- package/dist/src/multiLine/index.d.ts +1 -0
- package/dist/src/multiLine/index.js +77 -22
- package/dist/src/multiLine/inputbox.d.ts +3 -3
- package/dist/src/multiLine/inputbox.js +3 -7
- package/dist/src/multiLine/paramTag.d.ts +3 -4
- package/dist/src/multiLine/paramTag.js +6 -48
- package/dist/src/nowiki/comment.js +1 -1
- package/dist/src/nowiki/doubleUnderscore.js +4 -2
- package/dist/src/nowiki/index.js +34 -31
- package/dist/src/nowiki/listBase.d.ts +2 -1
- package/dist/src/nowiki/listBase.js +22 -8
- package/dist/src/nowiki/quote.d.ts +1 -1
- package/dist/src/nowiki/quote.js +1 -1
- package/dist/src/onlyinclude.js +1 -1
- package/dist/src/paramLine.d.ts +3 -0
- package/dist/src/paramLine.js +45 -7
- package/dist/src/parameter.js +1 -1
- package/dist/src/redirect.js +1 -1
- package/dist/src/table/base.d.ts +1 -1
- package/dist/src/table/base.js +4 -2
- package/dist/src/table/index.d.ts +2 -7
- package/dist/src/table/index.js +7 -54
- package/dist/src/table/td.js +9 -5
- package/dist/src/table/tr.d.ts +1 -1
- package/dist/src/tag/index.js +1 -1
- package/dist/src/tagPair/ext.js +33 -48
- package/dist/src/tagPair/index.js +6 -4
- package/dist/src/tagPair/translate.js +2 -2
- package/dist/src/transclude.d.ts +0 -6
- package/dist/src/transclude.js +16 -33
- package/dist/util/constants.js +5 -1
- package/dist/util/debug.js +81 -7
- package/dist/util/diff.js +17 -15
- package/dist/util/html.js +5 -3
- package/dist/util/selector.js +37 -0
- package/dist/util/sharable.d.mts +5 -1
- package/dist/util/sharable.js +69 -8
- package/dist/util/sharable.mjs +69 -7
- package/dist/util/string.js +31 -12
- package/extensions/dist/base.js +1 -1
- package/extensions/typings.d.ts +40 -0
- package/extensions/ui.css +1 -1
- package/i18n/en.json +2 -0
- package/i18n/zh-hans.json +31 -29
- package/i18n/zh-hant.json +32 -30
- package/package.json +19 -15
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toHtml = void 0;
|
|
4
|
+
const constants_1 = require("../util/constants");
|
|
5
|
+
const blockElems = 'table|h1|h2|h3|h4|h5|h6|pre|p|ul|ol|dl', antiBlockElems = 'td|th';
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
7
|
+
/<(?:table|\/(?:td|th)|\/?(?:tr|caption|dt|dd|li))\b/iu;
|
|
8
|
+
const openRegex = new RegExp(String.raw `<(?:${blockElems}|\/(?:${antiBlockElems})|\/?(?:tr|caption|dt|dd|li))\b`, 'iu');
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
10
|
+
/<(?:\/(?:h1|h2)|td|th|\/?(?:center|blockquote|div|hr|figure))\b/iu;
|
|
11
|
+
const closeRegex = new RegExp(String.raw `<(?:\/(?:${blockElems})|${antiBlockElems}|\/?(?:center|blockquote|div|hr|figure))\b`, 'iu');
|
|
12
|
+
/**
|
|
13
|
+
* 将展开后的节点转换为HTML
|
|
14
|
+
* @param token 展开后的节点
|
|
15
|
+
*/
|
|
16
|
+
const toHtml = (token) => {
|
|
17
|
+
constants_1.states.set(token, { headings: new Set(), categories: new Set() });
|
|
18
|
+
const lines = token.toHtmlInternal().split('\n');
|
|
19
|
+
let output = '', inBlockElem = false, pendingPTag = false, inBlockquote = false, lastParagraph = '';
|
|
20
|
+
const /** @ignore */ closeParagraph = () => {
|
|
21
|
+
if (lastParagraph) {
|
|
22
|
+
const result = `</${lastParagraph}>\n`;
|
|
23
|
+
lastParagraph = '';
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
return '';
|
|
27
|
+
};
|
|
28
|
+
for (let line of lines) {
|
|
29
|
+
const openMatch = openRegex.test(line), closeMatch = closeRegex.test(line);
|
|
30
|
+
if (openMatch || closeMatch) {
|
|
31
|
+
const blockquote = /<(\/?)blockquote[\s>](?!.*<\/?blockquote[\s>])/iu.exec(line)?.[1];
|
|
32
|
+
inBlockquote = blockquote === undefined ? inBlockquote : !blockquote;
|
|
33
|
+
pendingPTag = false;
|
|
34
|
+
output += closeParagraph();
|
|
35
|
+
inBlockElem = !closeMatch;
|
|
36
|
+
}
|
|
37
|
+
else if (!inBlockElem) {
|
|
38
|
+
if (line.startsWith(' ') && (lastParagraph === 'pre' || line.trim()) && !inBlockquote) {
|
|
39
|
+
if (lastParagraph !== 'pre') {
|
|
40
|
+
pendingPTag = false;
|
|
41
|
+
output += `${closeParagraph()}<pre>`;
|
|
42
|
+
lastParagraph = 'pre';
|
|
43
|
+
}
|
|
44
|
+
line = line.slice(1);
|
|
45
|
+
}
|
|
46
|
+
else if (/^(?:<link\b[^>]*>\s*)+$/iu.test(line)) {
|
|
47
|
+
if (pendingPTag) {
|
|
48
|
+
output += closeParagraph();
|
|
49
|
+
pendingPTag = false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else if (!line.trim()) {
|
|
53
|
+
if (pendingPTag) {
|
|
54
|
+
output += `${pendingPTag}<br>`;
|
|
55
|
+
pendingPTag = false;
|
|
56
|
+
lastParagraph = 'p';
|
|
57
|
+
}
|
|
58
|
+
else if (lastParagraph === 'p') {
|
|
59
|
+
pendingPTag = '</p><p>';
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
output += closeParagraph();
|
|
63
|
+
pendingPTag = '<p>';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else if (pendingPTag) {
|
|
67
|
+
output += pendingPTag;
|
|
68
|
+
pendingPTag = false;
|
|
69
|
+
lastParagraph = 'p';
|
|
70
|
+
}
|
|
71
|
+
else if (lastParagraph !== 'p') {
|
|
72
|
+
output += `${closeParagraph()}<p>`;
|
|
73
|
+
lastParagraph = 'p';
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (!pendingPTag) {
|
|
77
|
+
output += `${line}\n`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
output += closeParagraph();
|
|
81
|
+
const { categories } = constants_1.states.get(token);
|
|
82
|
+
constants_1.states.delete(token);
|
|
83
|
+
let html = output.trimEnd();
|
|
84
|
+
if (categories.size > 0) {
|
|
85
|
+
html += `
|
|
86
|
+
<div id="catlinks" class="catlinks"><div><a href="${token.normalizeTitle('Special:Categories', -1, { temporary: true }).getUrl()}" title="Special:Categories">Categories</a>: <ul>${[...categories].map(catlink => `<li>${catlink}</li>`).join('')}</div></div>`;
|
|
87
|
+
}
|
|
88
|
+
return html;
|
|
89
|
+
};
|
|
90
|
+
exports.toHtml = toHtml;
|
|
91
|
+
constants_1.parsers['toHtml'] = __filename;
|
|
@@ -132,6 +132,9 @@ const magicWords = [
|
|
|
132
132
|
'switch',
|
|
133
133
|
'plural',
|
|
134
134
|
'expr',
|
|
135
|
+
'!',
|
|
136
|
+
'=',
|
|
137
|
+
'filepath',
|
|
135
138
|
];
|
|
136
139
|
exports.expandedMagicWords = new Set(magicWords);
|
|
137
140
|
function urlFunction(config, args, local) {
|
|
@@ -274,7 +277,14 @@ const parseUrl = ({ testServer = '', articlePath = testServer }) => {
|
|
|
274
277
|
}, pad = ([arg0, arg1, arg2 = '0'], method) => arg0.includes('\0') ? arg0 : arg0[method](Number(arg1), strip(arg2)), anchorencode = (0, string_1.replaceEntities)(), special = (target, config) => {
|
|
275
278
|
const title = makeTitle(target, config, -1);
|
|
276
279
|
return title && title.ns === -1 ? title.prefix + title.main : 'Special:Badtitle';
|
|
277
|
-
}, contentmodels = {
|
|
280
|
+
}, contentmodels = {
|
|
281
|
+
js: ['JavaScript', 'javascript'],
|
|
282
|
+
css: ['CSS'],
|
|
283
|
+
json: ['JSON'],
|
|
284
|
+
vue: ['Vue'],
|
|
285
|
+
'sanitized-css': ['Sanitized CSS'],
|
|
286
|
+
Scribunto: ['Scribunto module'],
|
|
287
|
+
}, contentmodel = (i, extension) => contentmodels[extension][i] ?? extension, cmp = (x, y, decode) => {
|
|
278
288
|
const a = decode ? (0, string_1.decodeHtml)(x) : x, b = (0, string_1.decodeHtml)(y);
|
|
279
289
|
return a === b || Boolean(a && b) && Number(a) === Number(b);
|
|
280
290
|
}, isError = (s) => /<(?:strong|span|p|div)\s+(?:[^\s>]+\s+)*?class="\s*(?:[^"\s>]+\s+)*?error(?:\s[^">]*)?"/u.test(s), splitArg = (arg) => {
|
|
@@ -557,18 +567,18 @@ const expandMagicWord = (name, args, page = '', config = index_1.default.getConf
|
|
|
557
567
|
if (!title) {
|
|
558
568
|
return '';
|
|
559
569
|
}
|
|
560
|
-
const { ns: n, main, extension } = title, isSubpage = main.includes('/');
|
|
570
|
+
const { ns: n, main, extension } = title, i = arg0 === 'local' ? 0 : 1, isSubpage = main.includes('/');
|
|
561
571
|
if (isSubpage && (n === 10 || n === 828) && extension === 'css') {
|
|
562
|
-
return 'sanitized-css';
|
|
572
|
+
return contentmodel(i, 'sanitized-css');
|
|
563
573
|
}
|
|
564
574
|
else if (n === 828) {
|
|
565
575
|
if (extension === 'json') {
|
|
566
|
-
return '
|
|
576
|
+
return contentmodel(i, 'json');
|
|
567
577
|
}
|
|
568
|
-
return main.endsWith('/doc') ? '
|
|
578
|
+
return main.endsWith('/doc') ? 'wikiext' : contentmodel(i, 'Scribunto');
|
|
569
579
|
}
|
|
570
580
|
return (n === 8 || n === 2 && isSubpage) && extension && extension in contentmodels
|
|
571
|
-
?
|
|
581
|
+
? contentmodel(i, extension)
|
|
572
582
|
: 'wikitext';
|
|
573
583
|
}
|
|
574
584
|
case 'tag': {
|
|
@@ -590,7 +600,16 @@ const expandMagicWord = (name, args, page = '', config = index_1.default.getConf
|
|
|
590
600
|
attributes.set(key, value);
|
|
591
601
|
}
|
|
592
602
|
const tag = `<${tagName} ${[...attributes].map(([key, value]) => `${(0, string_1.sanitizeId)(key)}="${(0, string_1.sanitizeId)(value)}"`).join(' ')}${inner === undefined ? '/>' : `>${inner}</${tagName}>`}`;
|
|
593
|
-
|
|
603
|
+
if (!accum) {
|
|
604
|
+
return tag;
|
|
605
|
+
}
|
|
606
|
+
const { internal } = index_1.default;
|
|
607
|
+
index_1.default.internal = true;
|
|
608
|
+
const token = new index_2.Token(tag, config, accum).parseOnce(0);
|
|
609
|
+
index_1.default.internal = internal;
|
|
610
|
+
// @ts-expect-error sparse array
|
|
611
|
+
accum[accum.indexOf(token)] = undefined;
|
|
612
|
+
return token.firstChild.toString();
|
|
594
613
|
}
|
|
595
614
|
case 'rel2abs': {
|
|
596
615
|
const to = !arg0 || arg0.startsWith('/') ? `.${arg0}` : arg0, from = /^\.{1,2}(?:$|\/)/u.test(to) ? args[1] || page : '', abs = path_1.posix.join(from, to);
|
|
@@ -726,6 +745,28 @@ const expandMagicWord = (name, args, page = '', config = index_1.default.getConf
|
|
|
726
745
|
}
|
|
727
746
|
case 'expr':
|
|
728
747
|
return !Number.isNaN(Number(arg0)) && arg0;
|
|
748
|
+
case '!':
|
|
749
|
+
return '|';
|
|
750
|
+
case '=':
|
|
751
|
+
return '=';
|
|
752
|
+
case 'filepath': {
|
|
753
|
+
const title = makeTitle(`File:${arg0}`, config);
|
|
754
|
+
if (!title) {
|
|
755
|
+
return '';
|
|
756
|
+
}
|
|
757
|
+
const redirect = `Special:Redirect/file/${title.main}`, [, arg1, arg2] = args, param = arg1 === 'nowiki' ? arg2 : arg1, mt = param && /^(\d+(?:x\d+)?)(?:\s*px){0,2}$/u.exec(param);
|
|
758
|
+
if (!mt) {
|
|
759
|
+
return localurl(config, [redirect]);
|
|
760
|
+
}
|
|
761
|
+
const [width, height] = mt[1].split('x'), query = new URLSearchParams();
|
|
762
|
+
if (width) {
|
|
763
|
+
query.set('width', width);
|
|
764
|
+
}
|
|
765
|
+
if (height) {
|
|
766
|
+
query.set('height', height);
|
|
767
|
+
}
|
|
768
|
+
return localurl(config, [redirect, query.toString()]);
|
|
769
|
+
}
|
|
729
770
|
default:
|
|
730
771
|
throw new RangeError(`Unsupported magic word: ${name}`);
|
|
731
772
|
}
|
|
@@ -0,0 +1,415 @@
|
|
|
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
|
+
exports.loadLanguage = exports.Prism = void 0;
|
|
7
|
+
const constants_1 = require("../util/constants");
|
|
8
|
+
const index_1 = __importDefault(require("../index"));
|
|
9
|
+
exports.Prism = (() => {
|
|
10
|
+
try {
|
|
11
|
+
return require('prismjs');
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
})();
|
|
17
|
+
/**
|
|
18
|
+
* @see https://github.com/PrismJS/prism/blob/master/plugins/autoloader/prism-autoloader.js
|
|
19
|
+
*/
|
|
20
|
+
const dependencies = {
|
|
21
|
+
javascript: 'clike',
|
|
22
|
+
actionscript: 'javascript',
|
|
23
|
+
apex: [
|
|
24
|
+
'clike',
|
|
25
|
+
'sql',
|
|
26
|
+
],
|
|
27
|
+
arduino: 'cpp',
|
|
28
|
+
aspnet: [
|
|
29
|
+
'markup',
|
|
30
|
+
'csharp',
|
|
31
|
+
],
|
|
32
|
+
birb: 'clike',
|
|
33
|
+
bison: 'c',
|
|
34
|
+
c: 'clike',
|
|
35
|
+
csharp: 'clike',
|
|
36
|
+
cpp: 'c',
|
|
37
|
+
cfscript: 'clike',
|
|
38
|
+
chaiscript: [
|
|
39
|
+
'clike',
|
|
40
|
+
'cpp',
|
|
41
|
+
],
|
|
42
|
+
cilkc: 'c',
|
|
43
|
+
cilkcpp: 'cpp',
|
|
44
|
+
coffeescript: 'javascript',
|
|
45
|
+
crystal: 'ruby',
|
|
46
|
+
'css-extras': 'css',
|
|
47
|
+
d: 'clike',
|
|
48
|
+
dart: 'clike',
|
|
49
|
+
django: 'markup-templating',
|
|
50
|
+
ejs: [
|
|
51
|
+
'javascript',
|
|
52
|
+
'markup-templating',
|
|
53
|
+
],
|
|
54
|
+
etlua: [
|
|
55
|
+
'lua',
|
|
56
|
+
'markup-templating',
|
|
57
|
+
],
|
|
58
|
+
erb: [
|
|
59
|
+
'ruby',
|
|
60
|
+
'markup-templating',
|
|
61
|
+
],
|
|
62
|
+
fsharp: 'clike',
|
|
63
|
+
'firestore-security-rules': 'clike',
|
|
64
|
+
flow: 'javascript',
|
|
65
|
+
ftl: 'markup-templating',
|
|
66
|
+
gml: 'clike',
|
|
67
|
+
glsl: 'c',
|
|
68
|
+
go: 'clike',
|
|
69
|
+
gradle: 'clike',
|
|
70
|
+
groovy: 'clike',
|
|
71
|
+
haml: 'ruby',
|
|
72
|
+
handlebars: 'markup-templating',
|
|
73
|
+
haxe: 'clike',
|
|
74
|
+
hlsl: 'c',
|
|
75
|
+
idris: 'haskell',
|
|
76
|
+
java: 'clike',
|
|
77
|
+
javadoc: [
|
|
78
|
+
'markup',
|
|
79
|
+
'java',
|
|
80
|
+
'javadoclike',
|
|
81
|
+
],
|
|
82
|
+
jolie: 'clike',
|
|
83
|
+
jsdoc: [
|
|
84
|
+
'javascript',
|
|
85
|
+
'javadoclike',
|
|
86
|
+
'typescript',
|
|
87
|
+
],
|
|
88
|
+
'js-extras': 'javascript',
|
|
89
|
+
json5: 'json',
|
|
90
|
+
jsonp: 'json',
|
|
91
|
+
'js-templates': 'javascript',
|
|
92
|
+
kotlin: 'clike',
|
|
93
|
+
latte: [
|
|
94
|
+
'clike',
|
|
95
|
+
'markup-templating',
|
|
96
|
+
'php',
|
|
97
|
+
],
|
|
98
|
+
less: 'css',
|
|
99
|
+
lilypond: 'scheme',
|
|
100
|
+
liquid: 'markup-templating',
|
|
101
|
+
markdown: 'markup',
|
|
102
|
+
'markup-templating': 'markup',
|
|
103
|
+
mongodb: 'javascript',
|
|
104
|
+
n4js: 'javascript',
|
|
105
|
+
objectivec: 'c',
|
|
106
|
+
opencl: 'c',
|
|
107
|
+
parser: 'markup',
|
|
108
|
+
php: 'markup-templating',
|
|
109
|
+
phpdoc: [
|
|
110
|
+
'php',
|
|
111
|
+
'javadoclike',
|
|
112
|
+
],
|
|
113
|
+
'php-extras': 'php',
|
|
114
|
+
plsql: 'sql',
|
|
115
|
+
processing: 'clike',
|
|
116
|
+
protobuf: 'clike',
|
|
117
|
+
pug: [
|
|
118
|
+
'markup',
|
|
119
|
+
'javascript',
|
|
120
|
+
],
|
|
121
|
+
purebasic: 'clike',
|
|
122
|
+
purescript: 'haskell',
|
|
123
|
+
qsharp: 'clike',
|
|
124
|
+
qml: 'javascript',
|
|
125
|
+
qore: 'clike',
|
|
126
|
+
racket: 'scheme',
|
|
127
|
+
cshtml: [
|
|
128
|
+
'markup',
|
|
129
|
+
'csharp',
|
|
130
|
+
],
|
|
131
|
+
jsx: [
|
|
132
|
+
'markup',
|
|
133
|
+
'javascript',
|
|
134
|
+
],
|
|
135
|
+
tsx: [
|
|
136
|
+
'jsx',
|
|
137
|
+
'typescript',
|
|
138
|
+
],
|
|
139
|
+
reason: 'clike',
|
|
140
|
+
ruby: 'clike',
|
|
141
|
+
sass: 'css',
|
|
142
|
+
scss: 'css',
|
|
143
|
+
scala: 'java',
|
|
144
|
+
'shell-session': 'bash',
|
|
145
|
+
smarty: 'markup-templating',
|
|
146
|
+
solidity: 'clike',
|
|
147
|
+
soy: 'markup-templating',
|
|
148
|
+
sparql: 'turtle',
|
|
149
|
+
sqf: 'clike',
|
|
150
|
+
squirrel: 'clike',
|
|
151
|
+
stata: [
|
|
152
|
+
'mata',
|
|
153
|
+
'java',
|
|
154
|
+
'python',
|
|
155
|
+
],
|
|
156
|
+
't4-cs': [
|
|
157
|
+
't4-templating',
|
|
158
|
+
'csharp',
|
|
159
|
+
],
|
|
160
|
+
't4-vb': [
|
|
161
|
+
't4-templating',
|
|
162
|
+
'vbnet',
|
|
163
|
+
],
|
|
164
|
+
tap: 'yaml',
|
|
165
|
+
tt2: [
|
|
166
|
+
'clike',
|
|
167
|
+
'markup-templating',
|
|
168
|
+
],
|
|
169
|
+
textile: 'markup',
|
|
170
|
+
twig: 'markup-templating',
|
|
171
|
+
typescript: 'javascript',
|
|
172
|
+
v: 'clike',
|
|
173
|
+
vala: 'clike',
|
|
174
|
+
vbnet: 'basic',
|
|
175
|
+
velocity: 'markup',
|
|
176
|
+
wiki: 'markup',
|
|
177
|
+
xeora: 'markup',
|
|
178
|
+
'xml-doc': 'markup',
|
|
179
|
+
xquery: 'markup',
|
|
180
|
+
}, aliases = {
|
|
181
|
+
html: 'markup',
|
|
182
|
+
xml: 'markup',
|
|
183
|
+
svg: 'markup',
|
|
184
|
+
mathml: 'markup',
|
|
185
|
+
ssml: 'markup',
|
|
186
|
+
atom: 'markup',
|
|
187
|
+
rss: 'markup',
|
|
188
|
+
js: 'javascript',
|
|
189
|
+
g4: 'antlr4',
|
|
190
|
+
ino: 'arduino',
|
|
191
|
+
'arm-asm': 'armasm',
|
|
192
|
+
art: 'arturo',
|
|
193
|
+
adoc: 'asciidoc',
|
|
194
|
+
avs: 'avisynth',
|
|
195
|
+
avdl: 'avro-idl',
|
|
196
|
+
gawk: 'awk',
|
|
197
|
+
sh: 'bash',
|
|
198
|
+
shell: 'bash',
|
|
199
|
+
shortcode: 'bbcode',
|
|
200
|
+
rbnf: 'bnf',
|
|
201
|
+
oscript: 'bsl',
|
|
202
|
+
cs: 'csharp',
|
|
203
|
+
dotnet: 'csharp',
|
|
204
|
+
cfc: 'cfscript',
|
|
205
|
+
'cilk-c': 'cilkc',
|
|
206
|
+
'cilk-cpp': 'cilkcpp',
|
|
207
|
+
cilk: 'cilkcpp',
|
|
208
|
+
coffee: 'coffeescript',
|
|
209
|
+
conc: 'concurnas',
|
|
210
|
+
jinja2: 'django',
|
|
211
|
+
'dns-zone': 'dns-zone-file',
|
|
212
|
+
dockerfile: 'docker',
|
|
213
|
+
gv: 'dot',
|
|
214
|
+
eta: 'ejs',
|
|
215
|
+
xlsx: 'excel-formula',
|
|
216
|
+
xls: 'excel-formula',
|
|
217
|
+
gamemakerlanguage: 'gml',
|
|
218
|
+
po: 'gettext',
|
|
219
|
+
gni: 'gn',
|
|
220
|
+
ld: 'linker-script',
|
|
221
|
+
'go-mod': 'go-module',
|
|
222
|
+
hbs: 'handlebars',
|
|
223
|
+
mustache: 'handlebars',
|
|
224
|
+
hs: 'haskell',
|
|
225
|
+
idr: 'idris',
|
|
226
|
+
gitignore: 'ignore',
|
|
227
|
+
hgignore: 'ignore',
|
|
228
|
+
npmignore: 'ignore',
|
|
229
|
+
webmanifest: 'json',
|
|
230
|
+
kt: 'kotlin',
|
|
231
|
+
kts: 'kotlin',
|
|
232
|
+
kum: 'kumir',
|
|
233
|
+
tex: 'latex',
|
|
234
|
+
context: 'latex',
|
|
235
|
+
ly: 'lilypond',
|
|
236
|
+
emacs: 'lisp',
|
|
237
|
+
elisp: 'lisp',
|
|
238
|
+
'emacs-lisp': 'lisp',
|
|
239
|
+
md: 'markdown',
|
|
240
|
+
moon: 'moonscript',
|
|
241
|
+
n4jsd: 'n4js',
|
|
242
|
+
nani: 'naniscript',
|
|
243
|
+
objc: 'objectivec',
|
|
244
|
+
qasm: 'openqasm',
|
|
245
|
+
objectpascal: 'pascal',
|
|
246
|
+
px: 'pcaxis',
|
|
247
|
+
pcode: 'peoplecode',
|
|
248
|
+
plantuml: 'plant-uml',
|
|
249
|
+
pq: 'powerquery',
|
|
250
|
+
mscript: 'powerquery',
|
|
251
|
+
pbfasm: 'purebasic',
|
|
252
|
+
purs: 'purescript',
|
|
253
|
+
py: 'python',
|
|
254
|
+
qs: 'qsharp',
|
|
255
|
+
rkt: 'racket',
|
|
256
|
+
razor: 'cshtml',
|
|
257
|
+
rpy: 'renpy',
|
|
258
|
+
res: 'rescript',
|
|
259
|
+
robot: 'robotframework',
|
|
260
|
+
rb: 'ruby',
|
|
261
|
+
'sh-session': 'shell-session',
|
|
262
|
+
shellsession: 'shell-session',
|
|
263
|
+
smlnj: 'sml',
|
|
264
|
+
sol: 'solidity',
|
|
265
|
+
sln: 'solution-file',
|
|
266
|
+
rq: 'sparql',
|
|
267
|
+
sclang: 'supercollider',
|
|
268
|
+
t4: 't4-cs',
|
|
269
|
+
trickle: 'tremor',
|
|
270
|
+
troy: 'tremor',
|
|
271
|
+
trig: 'turtle',
|
|
272
|
+
ts: 'typescript',
|
|
273
|
+
tsconfig: 'typoscript',
|
|
274
|
+
uscript: 'unrealscript',
|
|
275
|
+
uc: 'unrealscript',
|
|
276
|
+
url: 'uri',
|
|
277
|
+
vb: 'visual-basic',
|
|
278
|
+
vba: 'visual-basic',
|
|
279
|
+
webidl: 'web-idl',
|
|
280
|
+
mathematica: 'wolfram',
|
|
281
|
+
nb: 'wolfram',
|
|
282
|
+
wl: 'wolfram',
|
|
283
|
+
xeoracube: 'xeora',
|
|
284
|
+
yml: 'yaml',
|
|
285
|
+
/** @see https://pygments.org/docs/lexers/ */
|
|
286
|
+
ada96: 'ada',
|
|
287
|
+
ada2005: 'ada',
|
|
288
|
+
aconf: 'apacheconf',
|
|
289
|
+
apache: 'apacheconf',
|
|
290
|
+
ahk: 'autohotkey',
|
|
291
|
+
mawk: 'awk',
|
|
292
|
+
nawk: 'awk',
|
|
293
|
+
ksh: 'bash',
|
|
294
|
+
zsh: 'bash',
|
|
295
|
+
openrc: 'bash',
|
|
296
|
+
qbasic: 'basic',
|
|
297
|
+
bat: 'batch',
|
|
298
|
+
dosbatch: 'batch',
|
|
299
|
+
winbatch: 'batch',
|
|
300
|
+
bf: 'brainfuck',
|
|
301
|
+
zeek: 'bro',
|
|
302
|
+
chai: 'chaiscript',
|
|
303
|
+
clj: 'clojure',
|
|
304
|
+
'coffee-script': 'coffeescript',
|
|
305
|
+
rocq: 'coq',
|
|
306
|
+
'rocq-prover': 'coq',
|
|
307
|
+
'c++': 'cpp',
|
|
308
|
+
cr: 'crystal',
|
|
309
|
+
'c#': 'csharp',
|
|
310
|
+
jinja: 'django',
|
|
311
|
+
udiff: 'diff',
|
|
312
|
+
graphviz: 'dot',
|
|
313
|
+
ex: 'elixir',
|
|
314
|
+
exs: 'elixir',
|
|
315
|
+
f90: 'fortran',
|
|
316
|
+
'f#': 'fsharp',
|
|
317
|
+
gd: 'gdscript',
|
|
318
|
+
cucumber: 'gherkin',
|
|
319
|
+
golang: 'go',
|
|
320
|
+
hxsl: 'haxe',
|
|
321
|
+
hx: 'haxe',
|
|
322
|
+
terraform: 'hcl',
|
|
323
|
+
tf: 'hcl',
|
|
324
|
+
i7: 'inform7',
|
|
325
|
+
cfg: 'ini',
|
|
326
|
+
dosini: 'ini',
|
|
327
|
+
'json-object': 'json',
|
|
328
|
+
react: 'jsx',
|
|
329
|
+
jl: 'julia',
|
|
330
|
+
kql: 'kusto',
|
|
331
|
+
'common-lisp': 'lisp',
|
|
332
|
+
'live-script': 'livescript',
|
|
333
|
+
make: 'makefile',
|
|
334
|
+
mf: 'makefile',
|
|
335
|
+
bsdmake: 'makefile',
|
|
336
|
+
nimrod: 'nim',
|
|
337
|
+
nixos: 'nix',
|
|
338
|
+
nsi: 'nsis',
|
|
339
|
+
nsh: 'nsis',
|
|
340
|
+
'objective-c': 'objectivec',
|
|
341
|
+
'obj-c': 'objectivec',
|
|
342
|
+
pl: 'perl',
|
|
343
|
+
php3: 'php',
|
|
344
|
+
php4: 'php',
|
|
345
|
+
php5: 'php',
|
|
346
|
+
pwsh: 'powershell',
|
|
347
|
+
posh: 'powershell',
|
|
348
|
+
ps1: 'powershell',
|
|
349
|
+
psm1: 'powershell',
|
|
350
|
+
jproperties: 'properties',
|
|
351
|
+
proto: 'protobuf',
|
|
352
|
+
jade: 'pug',
|
|
353
|
+
sage: 'python',
|
|
354
|
+
python3: 'python',
|
|
355
|
+
py3: 'python',
|
|
356
|
+
bazel: 'python',
|
|
357
|
+
starlark: 'python',
|
|
358
|
+
pyi: 'python',
|
|
359
|
+
qbs: 'qml',
|
|
360
|
+
splus: 'r',
|
|
361
|
+
s: 'r',
|
|
362
|
+
reasonml: 'reason',
|
|
363
|
+
restructuredtext: 'rest',
|
|
364
|
+
rst: 'rest',
|
|
365
|
+
duby: 'ruby',
|
|
366
|
+
rs: 'rust',
|
|
367
|
+
scm: 'scheme',
|
|
368
|
+
console: 'shell-session',
|
|
369
|
+
squeak: 'smalltalk',
|
|
370
|
+
st: 'smalltalk',
|
|
371
|
+
do: 'stata',
|
|
372
|
+
sc: 'supercollider',
|
|
373
|
+
vapi: 'vala',
|
|
374
|
+
'vb.net': 'vbnet',
|
|
375
|
+
v: 'verilog',
|
|
376
|
+
visualbasic: 'visual-basic',
|
|
377
|
+
mediawiki: 'wiki',
|
|
378
|
+
wikitext: 'wiki',
|
|
379
|
+
xqy: 'xquery',
|
|
380
|
+
xq: 'xquery',
|
|
381
|
+
xql: 'xquery',
|
|
382
|
+
xqm: 'xquery',
|
|
383
|
+
};
|
|
384
|
+
/**
|
|
385
|
+
* 加载Prism语言
|
|
386
|
+
* @param lang 语言名称
|
|
387
|
+
*/
|
|
388
|
+
const loadLanguage = (lang) => {
|
|
389
|
+
if (lang in exports.Prism.languages) {
|
|
390
|
+
return lang;
|
|
391
|
+
}
|
|
392
|
+
lang = aliases[lang] ?? lang;
|
|
393
|
+
if (lang === 'wiki') {
|
|
394
|
+
try {
|
|
395
|
+
const { default: registerWiki } = require('prism-wiki');
|
|
396
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
397
|
+
registerWiki(exports.Prism, index_1.default);
|
|
398
|
+
return lang;
|
|
399
|
+
}
|
|
400
|
+
catch { }
|
|
401
|
+
}
|
|
402
|
+
const dep = dependencies[lang];
|
|
403
|
+
if (typeof dep === 'string') {
|
|
404
|
+
(0, exports.loadLanguage)(dep);
|
|
405
|
+
}
|
|
406
|
+
else if (dep) {
|
|
407
|
+
for (const d of dep) {
|
|
408
|
+
(0, exports.loadLanguage)(d);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
require(`prismjs/components/prism-${lang}.js`);
|
|
412
|
+
return lang;
|
|
413
|
+
};
|
|
414
|
+
exports.loadLanguage = loadLanguage;
|
|
415
|
+
constants_1.parsers['loadLanguage'] = __filename;
|
package/dist/src/arg.js
CHANGED
|
@@ -193,7 +193,7 @@ let ArgToken = (() => {
|
|
|
193
193
|
}
|
|
194
194
|
/** @private */
|
|
195
195
|
print() {
|
|
196
|
-
return super.print({ pre: '{{{', post: '}}}', sep: '|' });
|
|
196
|
+
PRINT: return super.print({ pre: '{{{', post: '}}}', sep: '|' });
|
|
197
197
|
}
|
|
198
198
|
/** @private */
|
|
199
199
|
json(_, start = this.getAbsoluteIndex()) {
|
package/dist/src/attribute.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import Parser from '../index';
|
|
2
1
|
import { Token } from './index';
|
|
3
2
|
import { AtomToken } from './atom';
|
|
4
|
-
import type { LintError, AST } from '../base';
|
|
3
|
+
import type { LintError, Config, AST } from '../base';
|
|
5
4
|
import type { AttributesToken } from '../internal';
|
|
5
|
+
export declare const stages: {
|
|
6
|
+
'ext-attr': number;
|
|
7
|
+
'html-attr': number;
|
|
8
|
+
'table-attr': number;
|
|
9
|
+
};
|
|
6
10
|
export type AttributeTypes = 'ext-attr' | 'html-attr' | 'table-attr';
|
|
7
11
|
/**
|
|
8
12
|
* attribute of extension and HTML tags
|
|
@@ -38,11 +42,11 @@ export declare abstract class AttributeToken extends Token {
|
|
|
38
42
|
* @param type 标签类型
|
|
39
43
|
* @param tag 标签名
|
|
40
44
|
* @param key 属性名
|
|
45
|
+
* @param quotes 引号
|
|
41
46
|
* @param equal 等号
|
|
42
47
|
* @param value 属性值
|
|
43
|
-
* @param quotes 引号
|
|
44
48
|
*/
|
|
45
|
-
constructor(type: AttributeTypes, tag: string, key: string,
|
|
49
|
+
constructor(type: AttributeTypes, tag: string, key: string, quotes: readonly [string?, string?], config: Config, equal?: string, value?: string, accum?: Token[]);
|
|
46
50
|
/**
|
|
47
51
|
* Get the attribute value
|
|
48
52
|
*
|
|
@@ -85,5 +89,5 @@ export declare abstract class AttributeToken extends Token {
|
|
|
85
89
|
* @throws `Error` 复杂的style属性
|
|
86
90
|
* @throws `Error` 无CSS语言服务
|
|
87
91
|
*/
|
|
88
|
-
css(key: string, value?: string): string | undefined;
|
|
92
|
+
css(key: string, value?: string | number): string | undefined;
|
|
89
93
|
}
|