Skip to content

SyntaxToken (EN)

Bhsd edited this page Feb 9, 2025 · 3 revisions

Other Languages

Introduction

All kinds of special syntax. This class 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

lint

✅ Expand

returns: LintError[]
Report potential grammar errors.

// lint
var {firstChild: {firstChild}} = Parser.parse('{|\n|}');
assert.equal(firstChild, '{|');
assert.deepStrictEqual(firstChild.lint(), []);

cloneNode

Expand

returns: this
Deep clone the node.

// cloneNode (main)
var {firstChild: {firstChild}} = Parser.parse('{|');
assert.equal(firstChild, '{|');
assert.deepStrictEqual(firstChild.cloneNode(), firstChild);
Clone this wiki locally