Skip to content

Use decode-named-character-reference for HTML entities? #38

Closed

Description

@onmax

with #37, markdown-exit decodes entities with entities@9. its decodeHTML pulls in the full HTML5 decode table as a packed trie, which is 30 KiB minified / 13.5 KiB gzip and compresses poorly.

decode-named-character-reference is what micromark and remark use. it ships the same table as a plain object (35.0 / 11.6 KiB in Node), and its browser export decodes through the DOM, so browser bundles carry no table at all (0.2 / 0.2 KiB).

decoder KiB minified / gzip
entities@9 decodeHTML 30.0 / 13.5
decode-named-character-reference, Node 35.0 / 11.6
decode-named-character-reference, browser 0.2 / 0.2

the call sites are parser/inline/rules/entity.ts and common/utils.ts (unescapeAll). the API differs: it takes the name without & and ; and returns false for unknown names, so those two spots would change rather than just the import. the CommonMark fixtures should catch any decoding difference.

would you take a PR for this? happy to send one.

esbuild 0.28, minified ESM, gzip -9.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions