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

Other Languages

Introduction

Language conversion. This class mixes the properties and methods of ConverterFlagsToken.

All of the following properties and methods are not available in the Mini and Browser versions.

Properties

noConvert

type: boolean
Whether it is not converted, read-only.

// noConvert (main)
var {firstChild} = Parser.parse('-{x}-');
assert(firstChild.noConvert);

Methods

cloneNode

returns: this
Deep clone the node.

// cloneNode (main)
var {firstChild} = Parser.parse('-{}-');
assert.deepStrictEqual(firstChild.cloneNode(), firstChild);

toHtml

version added: 1.10.0

param: boolean Whether to disable line breaks
returns: string
Convert to HTML.

// toHtml (main)
var {firstChild} = Parser.parse('-{ a }-');
assert.strictEqual(firstChild.toHtml(), ' a ');
({firstChild} = Parser.parse('-{ a ; zh-cn : b }-'));
assert.strictEqual(firstChild.toHtml(), 'b');
({firstChild} = Parser.parse('-{R| a ; zh-cn : b }-'));
assert.strictEqual(firstChild.toHtml(), ' a ; zh-cn : b ');
({firstChild} = Parser.parse('-{H|a}-'));
assert.strictEqual(firstChild.toHtml(), '');