wikiparser-node 1.3.2 → 1.3.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/dist/parser/links.js +1 -1
- package/dist/src/html.js +7 -2
- package/dist/src/transclude.js +4 -3
- package/package.json +1 -1
package/dist/parser/links.js
CHANGED
|
@@ -14,7 +14,7 @@ const category_1 = require("../src/link/category");
|
|
|
14
14
|
*/
|
|
15
15
|
const parseLinks = (wikitext, config = Parser.getConfig(), accum = []) => {
|
|
16
16
|
const { parseQuotes } = require('./quotes');
|
|
17
|
-
const regex = /^((?:(?!\0\d+!\x7F)[^\n[\]{}|])+)(?:(\||\0\d+!\x7F)(.*?[^\]]))?\]\](.*)$/su, regexImg = /^((?:(?!\0\d+!\x7F)[^\n[\]{}|])+)(\||\0\d+!\x7F)(.*)$/su, regexExt = new RegExp(`^\\s*(?:${config.protocol})`, 'iu'), bits = wikitext.split('[[');
|
|
17
|
+
const regex = /^((?:(?!\0\d+!\x7F)[^\n[\]{}|])+)(?:(\||\0\d+!\x7F)(.*?[^\]]))?\]\](.*)$/su, regexImg = /^((?:(?!\0\d+!\x7F)[^\n[\]{}|])+)(\||\0\d+!\x7F)(.*)$/su, regexExt = new RegExp(`^\\s*(?:${config.protocol}|//)`, 'iu'), bits = wikitext.split('[[');
|
|
18
18
|
let s = bits.shift();
|
|
19
19
|
for (let i = 0; i < bits.length; i++) {
|
|
20
20
|
let mightBeImg = false, link, delimiter, text, after;
|
package/dist/src/html.js
CHANGED
|
@@ -81,8 +81,11 @@ class HtmlToken extends (0, attributesParent_1.attributesParent)((0, fixed_1.fix
|
|
|
81
81
|
}
|
|
82
82
|
/** @override */
|
|
83
83
|
text() {
|
|
84
|
-
const { closing } = this;
|
|
85
|
-
|
|
84
|
+
const { closing, name } = this, tag = `${this.#tag}${closing ? '' : super.text()}`, { html } = this.getAttribute('config');
|
|
85
|
+
if (html[2].includes(name)) {
|
|
86
|
+
return closing && name !== 'br' ? '' : `<${tag}>`;
|
|
87
|
+
}
|
|
88
|
+
return `<${closing ? '/' : ''}${tag}${this.#selfClosing && html[1].includes(name) ? '/' : ''}>`;
|
|
86
89
|
}
|
|
87
90
|
/** @private */
|
|
88
91
|
getAttribute(key) {
|
|
@@ -168,9 +171,11 @@ class HtmlToken extends (0, attributesParent_1.attributesParent)((0, fixed_1.fix
|
|
|
168
171
|
}
|
|
169
172
|
/** @override */
|
|
170
173
|
print() {
|
|
174
|
+
const { closing, name } = this, { html } = this.getAttribute('config');
|
|
171
175
|
return super.print({
|
|
172
176
|
pre: `<${this.closing ? '/' : ''}${this.#tag}`,
|
|
173
177
|
post: `${this.#selfClosing ? '/' : ''}>`,
|
|
178
|
+
class: closing && html[2].includes(name) && name !== 'br' ? 'html-invalid' : 'html',
|
|
174
179
|
});
|
|
175
180
|
}
|
|
176
181
|
/* NOT FOR BROWSER */
|
package/dist/src/transclude.js
CHANGED
|
@@ -53,10 +53,11 @@ class TranscludeToken extends index_1.Token {
|
|
|
53
53
|
title = arg.join(':').slice(mt.length);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
const isFunction = title.includes(':');
|
|
57
|
+
if (isFunction || parts.length === 0 && !this.#raw) {
|
|
58
|
+
const [magicWord, ...arg] = title.split(':'), cleaned = (0, string_1.removeComment)(magicWord), name = cleaned[arg.length > 0 ? 'trimStart' : 'trim'](), isSensitive = sensitive.includes(name), canonicalCame = isFunction && insensitive[name.toLowerCase()];
|
|
58
59
|
if (isSensitive || canonicalCame) {
|
|
59
|
-
this.setAttribute('name', canonicalCame
|
|
60
|
+
this.setAttribute('name', canonicalCame || name.toLowerCase());
|
|
60
61
|
this.type = 'magic-word';
|
|
61
62
|
const pattern = new RegExp(`^\\s*${name}\\s*$`, isSensitive ? 'u' : 'iu'), token = new syntax_1.SyntaxToken(magicWord, pattern, 'magic-word-name', config, accum, {
|
|
62
63
|
'Stage-1': ':', '!ExtToken': '',
|