OnlyincludeToken (EN) - bhsd-harry/wikiparser-node GitHub Wiki
Content wrapped in <onlyinclude> and </onlyinclude>. Only available when transcluded (i.e. Parser.parse(text, true)). This class inherits all the properties and methods of the Token class which are not repeated here.
✅ Available in the Mini and Browser versions.
🌐 Available in the Browser version.
Expand
type: string
The text content of the tag.
// innerText (main)
var {firstChild} = Parser.parse("<onlyinclude>a</onlyinclude>", true);
assert.equal(firstChild, "<onlyinclude>a</onlyinclude>");
assert.strictEqual(firstChild.innerText, "a");
firstChild.innerText = "[[a]]";
assert.equal(firstChild, "<onlyinclude>[[a]]</onlyinclude>");
assert.strictEqual(firstChild.firstChild.type, "link");✅ Expand
type: 'onlyinclude'
// type
var {firstChild} = Parser.parse("<onlyinclude>a</onlyinclude>", true);
assert.equal(firstChild, "<onlyinclude>a</onlyinclude>");
assert.strictEqual(firstChild.type, "onlyinclude");Expand
returns: this
Deep clone the node.
// cloneNode (main)
var {firstChild} = Parser.parse("<onlyinclude>a</onlyinclude>", true);
assert.deepStrictEqual(firstChild.cloneNode(), firstChild);🌐 Expand
returns: string
Output in HTML format.
// print (print)
var {firstChild} = Parser.parse("<onlyinclude>a</onlyinclude>", true);
assert.equal(
firstChild.print(),
`<span class="wpb-onlyinclude"><span class="wpb-ext"><onlyinclude></span>a<span class="wpb-ext"></onlyinclude></span></span>`,
);