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

Other Languages

Introduction

All kinds of special syntax. SyntaxToken inherits all the properties and methods of the Token class which are not repeated here.

✅ Available in the Mini and Browser versions.

Properties

type

✅ Expand

type: string
Type of the token.

// type
var {firstChild: {firstChild}} = Parser.parse('#redirect [[a]]');
assert.equal(firstChild, '#redirect ');
assert.strictEqual(firstChild.type, 'redirect-syntax');

({firstChild: {firstChild}} = Parser.parse('{{uc:a}}'));
assert.equal(firstChild, 'uc');
assert.strictEqual(firstChild.type, 'magic-word-name');

({firstChild: {firstChild}} = Parser.parse('{|'));
assert.equal(firstChild, '{|');
assert.strictEqual(firstChild.type, 'table-syntax');

Methods

cloneNode

Expand

returns: this
Deep clone the node.

// cloneNode (main)
var {firstChild: {firstChild}} = Parser.parse('{|');
assert.equal(firstChild, '{|');
assert.deepStrictEqual(firstChild.cloneNode(), firstChild);
⚠️ **GitHub.com Fallback** ⚠️