OnlyincludeToken (EN) - bhsd-harry/wikiparser-node GitHub Wiki

Other Languages

Introduction

Content wrapped in <onlyinclude> and </onlyinclude>. Only available when transcluded (i.e. Parser.parse(text, true)).

✅ Available in the Mini and Browser versions.
🌐 Available in the Browser version.

Properties

type

✅ Expand

type: 'onlyinclude'

// type
var {firstChild} = Parser.parse('<onlyinclude>a</onlyinclude>', true);
assert.equal(firstChild, '<onlyinclude>a</onlyinclude>');
assert.strictEqual(firstChild.type, 'onlyinclude');

innerText

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');

Methods

print

🌐 Expand

returns: string
Output in HTML format.

// print
var {firstChild} = Parser.parse('<onlyinclude>a</onlyinclude>', true);
assert.equal(
	firstChild.print(),
	`<span class="wpb-onlyinclude"><span class="wpb-ext">&lt;onlyinclude&gt;</span>a<span class="wpb-ext">&lt;/onlyinclude&gt;</span></span>`,
);

cloneNode

returns: this
Deep clone the node.

// cloneNode (main)
var {firstChild} = Parser.parse('<onlyinclude>a</onlyinclude>', true);
assert.deepStrictEqual(firstChild.cloneNode(), firstChild);
⚠️ **GitHub.com Fallback** ⚠️