Repository navigation
perf: decode named entities with character-entities - #40
Merged
serkodev merged 3 commits intoNov 3, 2026
Merged
Conversation
entities' decodeHTML ships a packed decode trie that gzip barely shrinks. decode-named-character-reference ships the same names as an object, and decodes through the DOM in browsers. It also only decodes complete names, so link destinations and titles keep unknown names like `&foo;` literal, as CommonMark requires.
decode-named-character-reference's browser export decodes through innerHTML, which fails in workers and under Trusted Types. A direct character-entities lookup behaves the same everywhere.
serkodev
force-pushed
the
feat/decode-named-character-reference
branch
from
November 3, 2026 07:58
35573c3 to
ec04f09
Compare
This was referenced Nov 3, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolves #38
because
entities'decodeHTMLships the HTML5 decode table as a packed trie, markdown-exit's bundle carries 31.5 KiB of table that gzip barely shrinks.character-entities, the table micromark and remark use, holds the same names as a plain object.this looks named references up in it directly, with no DOM, so it behaves the same in Node, browsers, and workers.
unescapeAllused non-strictdecodeHTML, so in link destinations and titles an unknown name like&foo;decoded its&prefix and became&foo;, and overlong numeric references likeAdecoded too. both now stay literal, as CommonMark requires, with a test.src/index.tsentities@7)esbuild 0.28, minified ESM, gzip -9. against
entities@9from #37 the table is 13.5 vs 11.7 KiB gzip.