SyntaxToken (EN) - bhsd-harry/wikiparser-node GitHub Wiki
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.
✅ Expand
type: string
Type of the token.
// type
var {firstChild: {firstChild}} = Parser.parse('#redirect [[a]]'),
lastChild;
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');
({firstChild: {lastChild}} = Parser.parse('==a== '));
assert.equal(lastChild, ' ');
assert.strictEqual(lastChild.type, 'heading-trail');
({firstChild: {firstChild}} = Parser.parse('<translate nowrap></translate>'));
assert.equal(firstChild, ' nowrap');
assert.strictEqual(firstChild.type, 'translate-attr');
Expand
returns: this
Deep clone the node.
// cloneNode (main)
var {firstChild: {firstChild}} = Parser.parse('{|');
assert.equal(firstChild, '{|');
assert.deepStrictEqual(firstChild.cloneNode(), firstChild);
✅ Expand
returns: LintError[]
Report potential grammar errors.
// lint
var {firstChild: {firstChild}} = Parser.parse('{|\n|}');
assert.equal(firstChild, '{|');
assert.deepStrictEqual(firstChild.lint(), []);