How semicolon handling works for HTML entities
mainThe library handles the distinction between "strict" HTML entities (which require a semicolon) and "legacy" entities (where the semicolon is optional) using the node header:
- Strict Entities: The encoder does not emit an explicit
';'child node. Instead, it sets the semicolon-required flag (bit 13) whenvalueLength > 0. During decoding, the unsuffixed key is automatically replaced with the suffixed variant. - Legacy Entities: These are represented as two separate nodes: one without the semicolon and one reached via an explicit
';'branch. These nodes do not set the semicolon-required flag.
This mechanism ensures correct semantic behavior while optimizing the trie structure.