-
Notifications
You must be signed in to change notification settings - Fork 3
ExtToken (EN)
Bhsd edited this page Jul 7, 2026
·
20 revisions
Extended tags. This class mixes the properties and methods of the AttributesToken class, and inherits all the properties and methods of the Token class which are not repeated here.
✅ Available in the Mini and Browser versions.
✅ Expand
type: string
The name of the tag, read-only.
// name
var {firstChild} = Parser.parse("<pre>a</pre>");
assert.equal(firstChild, "<pre>a</pre>");
assert.strictEqual(firstChild.name, "pre");✅ Expand
type: string
The text content of the tag, read-only.
// innerText
var {firstChild} = Parser.parse("<pre>a</pre>");
assert.equal(firstChild, "<pre>a</pre>");
assert.strictEqual(firstChild.innerText, "a");✅ Expand
returns: LintError[]
Report potential grammar errors.
// lint
var root = Parser.parse('<b title="a<ref>aa</ref>">aaa</b>'),
ref = root.querySelector("ext"),
firstChild;
assert.equal(ref, "<ref>aa</ref>");
assert.deepStrictEqual(ref.lint(), [
{
rule: "parsing-order",
severity: "error",
message: "extension tag in HTML tag attributes",
startLine: 0,
startCol: 11,
startIndex: 11,
endLine: 0,
endCol: 24,
endIndex: 24,
},
]);
({firstChild} = Parser.parse("<dynamicpagelist/>"));
assert.equal(firstChild, "<dynamicpagelist/>");
assert.deepStrictEqual(firstChild.lint(), [
{
rule: "void-ext",
severity: "error",
message: "<dynamicpagelist> should not be empty",
startLine: 0,
startCol: 0,
startIndex: 0,
endLine: 0,
endCol: 18,
endIndex: 18,
},
]);Expand
returns: this
Deep clone the node.
// cloneNode (main)
var {firstChild, lastChild} = Parser
.parse('<ref name="a">a</ref><ref name="a"/>'),
closed = firstChild.cloneNode(),
selfClosing = lastChild.cloneNode();
assert.equal(firstChild, '<ref name="a">a</ref>');
assert.equal(closed, '<ref name="a">a</ref>');
assert.equal(lastChild, '<ref name="a"/>');
assert.equal(selfClosing, '<ref name="a"/>');
assert.deepStrictEqual(closed, firstChild);
assert.deepStrictEqual(selfClosing, lastChild);Expand
version added: 1.10.0
returns: string
Convert to HTML.
// toHtml (main)
var {firstChild} = Parser.parse("<nowiki>a\nb</nowiki>");
assert.strictEqual(firstChild.toHtml(), "a b");
({firstChild} = Parser.parse("<pre id=a><nowiki>-{a\nb}-</nowiki></pre>"));
assert.strictEqual(firstChild.toHtml(), '<pre id="a">a b</pre>');
({firstChild} = Parser.parse("<poem class=b>a\nb</poem>"));
assert.strictEqual(
firstChild.toHtml(),
'<div class="b poem">\na<br>\nb\n</div>',
);对维基文本批量执行语法检查的命令行工具
轻量级的维基模板解析器
维基文本语言服务器协议实现
用于维基文本的 VS Code 扩展
A command-line tool that performs linting on Wikitext in bulk
A lightweight Wikitext template parser
An implementation of the Language Server Protocol for Wikitext
VS Code extension for Wikitext