-
Notifications
You must be signed in to change notification settings - Fork 2
IncludeToken (EN)
bhsd edited this page Jun 3, 2024
·
12 revisions
Table of Contents
Content wrapped in <includeonly>
and </includeonly>
when not transcluded, and content wrapped in <noinclude>
and </noinclude>
when transcluded.
✅ Available in the Mini and Browser versions.
✅ Expand
type: string
The name of the tag in lowercase, read-only.
// name
var {firstChild} = Parser.parse('<includeonly>a</includeonly>');
assert.equal(firstChild, '<includeonly>a</includeonly>');
assert.strictEqual(firstChild.name, 'includeonly');
✅ Expand
type: boolean
Whether the tag is closed.
// closed
var {firstChild} = Parser.parse('<includeonly>a');
assert.equal(firstChild, '<includeonly>a');
assert(!firstChild.closed);
firstChild.closed = true;
assert.equal(firstChild, '<includeonly>a</includeonly>');
✅ Expand
type: boolean
Whether the tag is self-closing.
// selfClosing
var {firstChild} = Parser.parse('<includeonly>a</includeonly>');
assert.equal(firstChild, '<includeonly>a</includeonly>');
assert(!firstChild.selfClosing);
firstChild.selfClosing = true;
assert.equal(firstChild, '<includeonly/>');
✅ Expand
type: string
The text content of the tag.
// innerText
var {firstChild} = Parser.parse('<includeonly>a</includeonly>');
assert.equal(firstChild, '<includeonly>a</includeonly>');
assert.strictEqual(firstChild.innerText, 'a');
// innerText (main)
var {firstChild} = Parser.parse('<includeonly>a</includeonly>');
firstChild.innerText = 'b';
assert.equal(firstChild, '<includeonly>b</includeonly>');
Expand
type: true
IncludeToken is invisible, read-only.
// hidden (main)
var {firstChild} = Parser.parse('<includeonly>a</includeonly>');
assert.equal(firstChild, '<includeonly>a</includeonly>');
assert(firstChild.hidden);
✅ Expand
version added: 1.3.2
returns: LintError[]
Report potential grammar errors.
// lint
var include = Parser.parse('<includeonly>a');
assert.equal(include, '<includeonly>a');
assert.deepEqual(include.lint(), [
{
rule: 'unclosed-comment',
severity: 'error',
message: 'unclosed <includeonly>',
startLine: 0,
startCol: 0,
startIndex: 0,
endLine: 0,
endCol: 14,
endIndex: 14,
suggestions: [
{
desc: 'close',
range: [14, 14],
text: '</includeonly>',
},
],
},
]);
Expand
returns: this
Deep clone the node.
// cloneNode (main)
var {
childNodes: [closed, selfClosing, open],
} = Parser.parse('<includeonly>a</includeonly><includeonly/><includeonly>b');
assert.equal(closed, '<includeonly>a</includeonly>');
assert.equal(selfClosing, '<includeonly/>');
assert.equal(open, '<includeonly>b');
assert.deepStrictEqual(closed.cloneNode(), closed);
assert.deepStrictEqual(selfClosing.cloneNode(), selfClosing);
assert.deepStrictEqual(open.cloneNode(), open);
Expand
Remove attributes. The attributes of the <includeonly>
tag have no effect.
// removeAttr (main)
var {firstChild} = Parser.parse('<includeonly name="a">a</includeonly>');
assert.equal(firstChild, '<includeonly name="a">a</includeonly>');
firstChild.removeAttr();
assert.equal(firstChild, '<includeonly>a</includeonly>');
对维基文本批量执行语法检查的命令行工具
用于维基文本的 ESLint 插件
A command-line tool that performs linting on Wikitext in bulk
ESLint plugin for Wikitext