wikiparser-node 1.18.2 → 1.18.4
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 -28
- package/bundle/bundle-lsp.min.js +31 -30
- package/bundle/bundle.min.js +30 -29
- package/config/minimum.json +7 -0
- package/dist/addon/token.js +37 -28
- 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 +14 -1
- package/dist/index.js +72 -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 +20 -15
- 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 +385 -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 +79 -37
- 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 +4 -8
- 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.d.ts +1 -0
- package/dist/src/table/index.js +7 -4
- package/dist/src/table/td.d.ts +1 -0
- package/dist/src/table/td.js +2 -3
- package/dist/src/table/trBase.js +31 -14
- package/dist/src/tagPair/index.js +2 -1
- package/dist/src/transclude.js +713 -657
- package/dist/util/debug.js +10 -3
- package/dist/util/diff.js +1 -1
- 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/util/debug.js
CHANGED
|
@@ -37,7 +37,14 @@ exports.isToken = isToken;
|
|
|
37
37
|
* @param inserted 插入的子节点
|
|
38
38
|
*/
|
|
39
39
|
const setChildNodes = (parent, position, deleteCount, inserted = []) => {
|
|
40
|
-
|
|
40
|
+
let nodes = parent.getChildNodes(), removed;
|
|
41
|
+
if (nodes.length === deleteCount) {
|
|
42
|
+
removed = nodes;
|
|
43
|
+
nodes = inserted;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
removed = nodes.splice(position, deleteCount, ...inserted);
|
|
47
|
+
}
|
|
41
48
|
for (let i = 0; i < inserted.length; i++) {
|
|
42
49
|
const node = inserted[i];
|
|
43
50
|
node.setAttribute('parentNode', parent);
|
|
@@ -46,8 +53,8 @@ const setChildNodes = (parent, position, deleteCount, inserted = []) => {
|
|
|
46
53
|
}
|
|
47
54
|
nodes[position - 1]?.setAttribute('nextSibling', nodes[position]);
|
|
48
55
|
nodes[position + inserted.length]?.setAttribute('previousSibling', nodes[position + inserted.length - 1]);
|
|
49
|
-
/* NOT FOR BROWSER */
|
|
50
56
|
parent.setAttribute('childNodes', nodes);
|
|
57
|
+
/* NOT FOR BROWSER */
|
|
51
58
|
for (const node of removed) {
|
|
52
59
|
node.setAttribute('parentNode', undefined);
|
|
53
60
|
}
|
|
@@ -84,7 +91,7 @@ const undo = (e, data) => {
|
|
|
84
91
|
(0, exports.setChildNodes)(target.parentNode, data.position, 1, [data.oldToken]);
|
|
85
92
|
break;
|
|
86
93
|
case 'text':
|
|
87
|
-
target.
|
|
94
|
+
target.setAttribute('data', data.oldText);
|
|
88
95
|
break;
|
|
89
96
|
/* istanbul ignore next */
|
|
90
97
|
default:
|
package/dist/util/diff.js
CHANGED
|
@@ -31,7 +31,7 @@ const cmd = (command, args) => new Promise(resolve => {
|
|
|
31
31
|
shell = (0, child_process_1.spawn)(command, args);
|
|
32
32
|
timer = setTimeout(() => {
|
|
33
33
|
shell.kill('SIGINT');
|
|
34
|
-
}, 60 *
|
|
34
|
+
}, 60 * 1e3);
|
|
35
35
|
let buf = '';
|
|
36
36
|
shell.stdout.on('data', data => {
|
|
37
37
|
buf += String(data);
|
package/dist/util/string.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeCommentLine = exports.newline = exports.sanitizeAlt = exports.sanitizeId = exports.sanitizeAttr = exports.sanitize = exports.normalizeSpace = exports.encode = exports.print = exports.escape = exports.noWrap = exports.decodeNumber = exports.decodeHtml = exports.text = exports.escapeRegExp = exports.removeComment = exports.tidy = exports.extUrlChar = exports.extUrlCharFirst = exports.zs = exports.rawurldecode = void 0;
|
|
3
|
+
exports.removeCommentLine = exports.newline = exports.sanitizeAlt = exports.sanitizeId = exports.sanitizeAttr = exports.sanitize = exports.normalizeSpace = exports.encode = exports.print = exports.escape = exports.noWrap = exports.decodeNumber = exports.decodeHtml = exports.decodeHtmlBasic = exports.text = exports.escapeRegExp = exports.removeComment = exports.tidy = exports.extUrlChar = exports.extUrlCharFirst = exports.zs = exports.rawurldecode = void 0;
|
|
4
4
|
var common_1 = require("@bhsd/common");
|
|
5
5
|
Object.defineProperty(exports, "rawurldecode", { enumerable: true, get: function () { return common_1.rawurldecode; } });
|
|
6
6
|
exports.zs = String.raw ` \xA0\u1680\u2000-\u200A\u202F\u205F\u3000`;
|
|
@@ -27,9 +27,8 @@ exports.escapeRegExp = factory(/[\\{}()|.?*+^$[\]]/gu, String.raw `\$&`);
|
|
|
27
27
|
const text = (childNodes, separator = '') => childNodes.map(child => typeof child === 'string' ? child : child.text()).join(separator);
|
|
28
28
|
exports.text = text;
|
|
29
29
|
const names = { lt: '<', gt: '>', lbrack: '[', rbrack: ']', lbrace: '{', rbrace: '}', nbsp: ' ', amp: '&', quot: '"' };
|
|
30
|
-
/* istanbul ignore next */
|
|
31
30
|
/** decode HTML entities */
|
|
32
|
-
|
|
31
|
+
exports.decodeHtmlBasic = factory(/&(?:#(\d+|[Xx][\da-fA-F]+)|([lg]t|[LG]T|[lr]brac[ke]|nbsp|amp|AMP|quot|QUOT));/gu, (_, code, name) => code
|
|
33
32
|
? String.fromCodePoint(Number((/^x/iu.test(code) ? '0' : '') + code))
|
|
34
33
|
: names[name.toLowerCase()]);
|
|
35
34
|
/**
|
|
@@ -48,7 +47,7 @@ const decodeHtml = (str) => {
|
|
|
48
47
|
}
|
|
49
48
|
/* istanbul ignore next */
|
|
50
49
|
/* NOT FOR BROWSER ONLY END */
|
|
51
|
-
return decodeHtmlBasic(str);
|
|
50
|
+
return (0, exports.decodeHtmlBasic)(str);
|
|
52
51
|
};
|
|
53
52
|
exports.decodeHtml = decodeHtml;
|
|
54
53
|
/** decode numbered HTML entities */
|
|
@@ -85,7 +84,7 @@ exports.encode = factory(/[<>[\]#|=]+/gu, encodeURIComponent);
|
|
|
85
84
|
const normalizeSpace = (token) => {
|
|
86
85
|
if (token) {
|
|
87
86
|
for (const child of token.childNodes) {
|
|
88
|
-
if (child.type === 'text') {
|
|
87
|
+
if (child.type === 'text' && child.data.includes('\n')) {
|
|
89
88
|
child.replaceData(child.data.replace(/\n+/gu, ' '));
|
|
90
89
|
}
|
|
91
90
|
}
|
package/extensions/dist/base.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
var _a;
|
|
3
|
-
const version = '1.18.
|
|
3
|
+
const version = '1.18.4', src = (_a = document.currentScript) === null || _a === void 0 ? void 0 : _a.src, file = /\/extensions\/dist\/base\.(?:min\.)?js$/u, CDN = src && file.test(src)
|
|
4
4
|
? src.replace(file, '')
|
|
5
5
|
: `https://testingcf.jsdelivr.net/npm/wikiparser-node@${version}`;
|
|
6
6
|
const workerJS = () => {
|
|
@@ -221,7 +221,7 @@ const splitNewLine = (html) => {
|
|
|
221
221
|
};
|
|
222
222
|
const getGutter = (container) => container.querySelector('.wikiparser-line-numbers');
|
|
223
223
|
const size = (html) => {
|
|
224
|
-
const container = html.parentElement, gutter = getGutter(container);
|
|
224
|
+
const container = html.parentElement, { isContentEditable } = html, { clientHeight } = container, gutter = getGutter(container);
|
|
225
225
|
if (!gutter) {
|
|
226
226
|
intersectionObserver.unobserve(html);
|
|
227
227
|
return;
|
|
@@ -230,6 +230,9 @@ const size = (html) => {
|
|
|
230
230
|
const start = Number(html.dataset['start'] || 1), lines = splitNewLine(html), width = `${String(lines.length + start - 1).length + 1.5}ch`;
|
|
231
231
|
html.style.marginLeft = width;
|
|
232
232
|
gutter.style.width = width;
|
|
233
|
+
if (isContentEditable) {
|
|
234
|
+
gutter.style.minHeight = `${clientHeight + 1}px`;
|
|
235
|
+
}
|
|
233
236
|
const sizer = document.createElement('span'), { style: { paddingLeft, paddingRight } } = html;
|
|
234
237
|
sizer.className = 'wikiparser-sizer';
|
|
235
238
|
sizer.style.paddingLeft = paddingLeft;
|
|
@@ -250,11 +253,10 @@ const size = (html) => {
|
|
|
250
253
|
lastTop = top;
|
|
251
254
|
}
|
|
252
255
|
if (line) {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
line.style.height = `${container.clientHeight}px`;
|
|
256
|
+
if (isContentEditable) {
|
|
257
|
+
line.style.height = `${clientHeight}px`;
|
|
256
258
|
}
|
|
257
|
-
else if (
|
|
259
|
+
else if (html.offsetHeight <= clientHeight) {
|
|
258
260
|
line.style.height = `${container.getBoundingClientRect().top + container.scrollHeight - lastTop}px`;
|
|
259
261
|
container.style.overflowY = 'hidden';
|
|
260
262
|
}
|
package/extensions/dist/lint.js
CHANGED
|
@@ -54,7 +54,7 @@ class Linter {
|
|
|
54
54
|
async monaco(wikitext) {
|
|
55
55
|
return (await this.queue(wikitext))
|
|
56
56
|
.map(({ startLine, startCol, endLine, endCol, severity, message, rule }) => ({
|
|
57
|
-
source:
|
|
57
|
+
source: 'WikiLint',
|
|
58
58
|
startLineNumber: startLine + 1,
|
|
59
59
|
startColumn: startCol + 1,
|
|
60
60
|
endLineNumber: endLine + 1,
|
package/extensions/es7/base.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
var _a;
|
|
12
|
-
const version = '1.18.
|
|
12
|
+
const version = '1.18.4', src = (_a = document.currentScript) === null || _a === void 0 ? void 0 : _a.src, file = /\/extensions\/dist\/base\.(?:min\.)?js$/u, CDN = src && file.test(src)
|
|
13
13
|
? src.replace(file, '')
|
|
14
14
|
: `https://testingcf.jsdelivr.net/npm/wikiparser-node@${version}`;
|
|
15
15
|
const workerJS = () => {
|
|
@@ -230,7 +230,7 @@ const splitNewLine = (html) => {
|
|
|
230
230
|
};
|
|
231
231
|
const getGutter = (container) => container.querySelector('.wikiparser-line-numbers');
|
|
232
232
|
const size = (html) => {
|
|
233
|
-
const container = html.parentElement, gutter = getGutter(container);
|
|
233
|
+
const container = html.parentElement, { isContentEditable } = html, { clientHeight } = container, gutter = getGutter(container);
|
|
234
234
|
if (!gutter) {
|
|
235
235
|
intersectionObserver.unobserve(html);
|
|
236
236
|
return;
|
|
@@ -239,6 +239,9 @@ const size = (html) => {
|
|
|
239
239
|
const start = Number(html.dataset['start'] || 1), lines = splitNewLine(html), width = `${String(lines.length + start - 1).length + 1.5}ch`;
|
|
240
240
|
html.style.marginLeft = width;
|
|
241
241
|
gutter.style.width = width;
|
|
242
|
+
if (isContentEditable) {
|
|
243
|
+
gutter.style.minHeight = `${clientHeight + 1}px`;
|
|
244
|
+
}
|
|
242
245
|
const sizer = document.createElement('span'), { style: { paddingLeft, paddingRight } } = html;
|
|
243
246
|
sizer.className = 'wikiparser-sizer';
|
|
244
247
|
sizer.style.paddingLeft = paddingLeft;
|
|
@@ -259,11 +262,10 @@ const size = (html) => {
|
|
|
259
262
|
lastTop = top;
|
|
260
263
|
}
|
|
261
264
|
if (line) {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
line.style.height = `${container.clientHeight}px`;
|
|
265
|
+
if (isContentEditable) {
|
|
266
|
+
line.style.height = `${clientHeight}px`;
|
|
265
267
|
}
|
|
266
|
-
else if (
|
|
268
|
+
else if (html.offsetHeight <= clientHeight) {
|
|
267
269
|
line.style.height = `${container.getBoundingClientRect().top + container.scrollHeight - lastTop}px`;
|
|
268
270
|
container.style.overflowY = 'hidden';
|
|
269
271
|
}
|
package/extensions/es7/lint.js
CHANGED
|
@@ -68,7 +68,7 @@ class Linter {
|
|
|
68
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
69
69
|
return (yield this.queue(wikitext))
|
|
70
70
|
.map(({ startLine, startCol, endLine, endCol, severity, message, rule }) => ({
|
|
71
|
-
source:
|
|
71
|
+
source: 'WikiLint',
|
|
72
72
|
startLineNumber: startLine + 1,
|
|
73
73
|
startColumn: startCol + 1,
|
|
74
74
|
endLineNumber: endLine + 1,
|
package/extensions/ui.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.wikiparse-container{position:relative;-webkit-text-size-adjust:none}.wikiparser{white-space:pre-wrap;overflow-wrap:break-word;word-break:break-all;font-family:monospace;border:1.5px solid #dedede;background-color:#fff}.wikiparser.wikiparse-container{padding:4px 0;overflow-y:auto}.wikiparse-container>.wpb-root{padding:0 6px;display:block;position:relative;overflow-y:hidden!important}.wikiparser-line-numbers{position:absolute;top:0;left:0;display:inline-block;background-color:#f5f5f5;color:#6c6c6c;border-right:1px solid #ddd;padding:4px 0}.wikiparser-line-numbers>span{display:inline-block;width:calc(100% - .5ch);text-align:right}.wikiparser-sizer{position:absolute;top:0;left:0;right:0;visibility:hidden;z-index:-1;padding:0 6px}.wpb-
|
|
1
|
+
.wikiparse-container{position:relative;-webkit-text-size-adjust:none}.wikiparser{white-space:pre-wrap;overflow-wrap:break-word;word-break:break-all;font-family:monospace;border:1.5px solid #dedede;background-color:#fff}.wikiparser.wikiparse-container{padding:4px 0;overflow-y:auto}.wikiparse-container>.wpb-root{padding:0 6px;display:block;position:relative;overflow-y:hidden!important}.wikiparser-line-numbers{position:absolute;top:0;left:0;display:inline-block;background-color:#f5f5f5;color:#6c6c6c;border-right:1px solid #ddd;padding:4px 0}.wikiparser-line-numbers>span{display:inline-block;width:calc(100% - .5ch);text-align:right}.wikiparser-sizer{position:absolute;top:0;left:0;right:0;visibility:hidden;z-index:-1;padding:0 6px}.wpb-table-inter{color:#d73333;font-weight:400;text-decoration:underline wavy 1px}.wpb-hidden,.wpb-noinclude,.wpb-include,.wpb-comment,.wpb-attr-dirty{color:#7b8c8f;font-weight:400;font-style:italic}.wpb-ext,.wpb-html{color:#14866d;font-weight:700}.wpb-ext-attrs,.wpb-html-attrs{font-weight:400}.wpb-ext-attr>.wpb-attr-value,.wpb-html-attr>.wpb-attr-value{color:#179b1c}.wpb-ext-inner{color:initial;font-weight:400;background-color:#00000008}.wpb-arg{color:#ac6600;font-weight:700}.wpb-arg-default{color:#ad9300;font-weight:400}.wpb-template{color:#80c;font-weight:700;background-color:#7700aa08}.wpb-magic-word{color:#a11;font-weight:700;background-color:#aa111108}.wpb-invoke-module,.wpb-invoke-function{color:#bf3e13;font-weight:400}.wpb-parameter{font-weight:400}.wpb-template>.wpb-parameter,.wpb-invoke-function~.wpb-parameter{color:#b0c}.wpb-parameter-value{color:initial}.wpb-heading,.wpb-image-parameter{color:#0076dd}.wpb-heading-title{color:initial;font-weight:700}.wpb-table,.wpb-tr,.wpb-td{color:#d08;font-weight:700}.wpb-table-attrs{font-weight:400}.wpb-table-attr>.wpb-attr-value{color:#f500d4}.wpb-td-inner{color:initial;font-weight:400}.wpb-double-underscore,.wpb-hr,.wpb-quote,.wpb-list,.wpb-dd,.wpb-redirect-syntax{color:#0076dd;font-weight:700;background-color:#eee}.wpb-link,.wpb-category,.wpb-file,.wpb-gallery-image,.wpb-imagemap-image,.wpb-redirect-target,.wpb-ext-link,.wpb-free-ext-link,.wpb-magic-link{color:#000aaa;background-color:#22119908}.wpb-link-text,.wpb-image-caption,.wpb-ext-link-text{color:initial}.wpb-converter{color:#b68;font-weight:700}.wpb-converter-rule{font-weight:400}.wpb-converter-rule-from,.wpb-converter-rule-to,.wpb-converter-noconvert{color:initial}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wikiparser-node",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.4",
|
|
4
4
|
"description": "A Node.js parser for MediaWiki markup with AST",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mediawiki",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"test:unit": "mocha dist/test/test.js",
|
|
63
63
|
"test:clonenode": "CLONENODE=1 npm run test:unit",
|
|
64
64
|
"test:parser": "mocha dist/test/parserTests.js",
|
|
65
|
-
"test": "npm run test:unit && npm run test:parser",
|
|
65
|
+
"test": "npm run test:unit && npm run test:clonenode && npm run test:parser",
|
|
66
66
|
"test:end": "pkill -x http-server",
|
|
67
67
|
"test:real": "node dist/test/real.js"
|
|
68
68
|
},
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
]
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@bhsd/common": "^0.
|
|
80
|
+
"@bhsd/common": "^0.9.1",
|
|
81
81
|
"vscode-languageserver-types": "^3.17.5"
|
|
82
82
|
},
|
|
83
83
|
"optionalDependencies": {
|