Class
HtmlEntityDecoder
class HtmlEntityDecoder extends EntityDecoderBaseDefined in decode.ts:982
Streaming decoder for HTML entities.
When the entity fits inside the current chunk (the common case), the lookup runs directly on the chunk via the same length-probe scheme as the synchronous decoder; chunk-boundary runs use a reusable character buffer.
Constructors
new HtmlEntityDecoder(emitCodePoint: (cp: number, consumed: number) => void, errors?: EntityErrorProducer | undefined): HtmlEntityDecoderParameters
emitCodePoint: (cp: number, consumed: number) => voidThe 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
consumedvalue.errors?: EntityErrorProducer | undefinedAn object that is used to produce errors.
Returns
Inherited from EntityDecoderBase.constructor
Properties
consumed protected
decode.ts:722protected consumed: numberCharacters that were consumed while parsing an entity.
Inherited from EntityDecoderBase.consumed
decodeMode protected
decode.ts:726protected decodeMode: DecodingModeThe mode in which the decoder is operating.
Inherited from EntityDecoderBase.decodeMode
emitCodePoint protected readonly
decode.ts:741protected readonly emitCodePoint: (cp: number, consumed: number) => voidThe 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.
Parameters
cp: numberconsumed: numberThe number of bytes consumed by the decoder.
Returns
void
Inherited from EntityDecoderBase.emitCodePoint
errors protected readonly optional
decode.ts:746protected readonly errors?: EntityErrorProducer | undefinedAn object that is used to produce errors.
Inherited from EntityDecoderBase.errors
replaceNumericCodePoint protected readonly
decode.ts:729protected readonly replaceNumericCodePoint: (codePoint: number) => numberReplacement rules for numeric character references.
Parameters
codePoint: number
Returns
number
Inherited from EntityDecoderBase.replaceNumericCodePoint
result protected
decode.ts:724protected result: numberAccumulated numeric code point, or a packed partial XML name.
Inherited from EntityDecoderBase.result
state protected
decode.ts:720protected state: numberThe current state of the decoder.
Inherited from EntityDecoderBase.state
Methods
end(): numberSignal to the parser that the end of the input was reached.
Remaining data will be emitted and relevant errors will be produced.
Returns
number
The number of characters consumed.
Inherited from EntityDecoderBase.end
endNamedEntity protected
decode.ts:1130protected endNamedEntity(): numberResolve a named entity that was still incomplete when the input ended.
Returns
number
The number of characters that were consumed.
Overrides EntityDecoderBase.endNamedEntity
startEntity(decodeMode: DecodingMode): voidResets the instance to make it reusable.
Parameters
decodeMode: DecodingModeEntity decoding mode to use.
Returns
void
Overrides EntityDecoderBase.startEntity
stateNamedEntity protected
decode.ts:1009protected stateNamedEntity(input: string, offset: number): numberDecode a named entity.
Parameters
input: stringThe string containing the entity (or a continuation of the entity).
offset: numberThe current offset.
Returns
number
The number of characters that were consumed, or -1 if the entity is incomplete.
Overrides EntityDecoderBase.stateNamedEntity
write(input: string, offset: number): numberWrite an entity to the decoder. This can be called multiple times with partial entities. If the entity is incomplete, the decoder will return -1.
Parameters
input: stringThe string containing the entity (or a continuation of the entity).
offset: numberThe offset at which the entity begins. Should be 0 if this is not the first call.
Returns
number
The number of characters that were consumed, or -1 if the entity is incomplete.
Inherited from EntityDecoderBase.write