The tree used to decode entities.
The function that is called when a codepoint is decoded.
For multi-byte named entities, this will be called multiple times,
with the second codepoint, and the same consumed
value.
The decoded codepoint.
The number of bytes consumed by the decoder.
Optional
errors: EntityErrorProducerAn object that is used to produce errors.
Private
consumedCharacters that were consumed while parsing an entity.
Private
decodeThe mode in which the decoder is operating.
Private
Readonly
decodeThe tree used to decode entities.
Private
Readonly
emitThe function that is called when a codepoint is decoded.
For multi-byte named entities, this will be called multiple times,
with the second codepoint, and the same consumed
value.
The number of bytes consumed by the decoder.
Private
Optional
Readonly
errorsAn object that is used to produce errors.
Private
excessThe number of characters that were consumed in excess.
Private
resultThe result of the entity.
Either the result index of a numeric entity, or the codepoint of a numeric entity.
Private
stateThe current state of the decoder.
Private
treeThe current index in the decode tree.
Private
addPrivate
emitEmit a named entity.
The index of the entity in the decode tree.
The number of bytes in the entity.
The number of characters consumed.
The number of characters consumed.
Private
emitPrivate
emitValidate and emit a numeric entity.
Implements the logic from the Hexademical character reference start state
and Numeric character reference end state
in the HTML spec.
The last code point of the entity. Used to see if the entity was terminated with a semicolon.
The minimum number of characters that should be consumed. Used to validate that at least one digit was consumed.
The number of characters that were consumed.
Resets the instance to make it reusable.
Private
stateParses a named entity.
Equivalent to the Named character reference state
in the HTML spec.
The string containing the entity (or a continuation of the entity).
The current offset.
The number of characters that were consumed, or -1 if the entity is incomplete.
Private
stateParses a decimal numeric entity.
Equivalent to the Decimal character reference state
in the HTML spec.
The string containing the entity (or a continuation of the entity).
The current offset.
The number of characters that were consumed, or -1 if the entity is incomplete.
Private
stateParses a hexadecimal numeric entity.
Equivalent to the Hexademical character reference state
in the HTML spec.
The string containing the entity (or a continuation of the entity).
The current offset.
The number of characters that were consumed, or -1 if the entity is incomplete.
Private
stateSwitches between the numeric decimal and hexadecimal states.
Equivalent to the Numeric character reference state
in the HTML spec.
The string containing the entity (or a continuation of the entity).
The current offset.
The number of characters that were consumed, or -1 if the entity is incomplete.
Write an entity to the decoder. This can be called multiple times with partial entities. If the entity is incomplete, the decoder will return -1.
Mirrors the implementation of getDecoder
, but with the ability to stop decoding if the
entity is incomplete, and resume when the next string is written.
The offset at which the entity begins. Should be 0 if this is not the first call.
The number of characters that were consumed, or -1 if the entity is incomplete.
Token decoder with support of writing partial entities.