Class: TokenTransformManager

wt2html/TokenTransformManager~TokenTransformManager(env, options)

Base class for token transform managers.

Constructor

new TokenTransformManager(env, options)

...
Parameters:
Name Type Description
env MWParserEnvironment
options Object
Source:

Extends

Methods

addListenersOn(tokenEmitter)

Register to a token source, normally the tokenizer.

Register to a token source, normally the tokenizer. The event emitter emits a 'chunk' event with a chunk of tokens, and signals the end of tokens by triggering the 'end' event. XXX: Perform registration directly in the constructor?

Parameters:
Name Type Description
tokenEmitter EventEmitter

Token event emitter.

Source:

addTransform(transformation, debugName, rank, type, name)

Add a transform registration.

Add a transform registration.

Parameters:
Name Type Description
transformation function
Properties
Name Type Description
token Token
frame Object
cb function
Properties
Name Type Description
result Object
Properties
Name Type Description
tokens Array.<Token>
return Object
Properties
Name Type Description
tokens Array.<Token>
debugName string

Debug string to identify the transformer in a trace.

rank number

A number in [0,3) with:

  • [0,1) in-order on input token stream,
  • [1,2) out-of-order and
  • [2,3) in-order on output token stream.
type string

One of 'tag', 'text', 'newline', 'comment', 'end', 'martian' (unknown token), 'any' (any token, matched before other matches).

name string

Tag name for tags, omitted for non-tags

Source:

removeTransform(rank, type, name)

Remove a transform registration.

Remove a transform registration.

Parameters:
Name Type Description
rank number

A number in [0,3) with:

  • [0,1) in-order on input token stream,
  • [1,2) out-of-order and
  • [2,3) in-order on output token stream.
type string

One of 'tag', 'text', 'newline', 'comment', 'end', 'martian' (unknown token), 'any' (any token, matched before other matches).

name string

Tag name for tags, omitted for non-tags.

Source: