Entities

Converts Unicode characters to their HTML entity equivalents so they render correctly across email clients.

Usage

The transformer is enabled by default, so you don't need to configure anything. It processes text nodes in the DOM and replaces known Unicode characters with their HTML entities.

The default entity map covers common characters used in email:

CharacterEntity
Zero-width joiner‍
Zero-width non-joiner‌
Non-breaking space 
Soft hyphen­
Zero-width space​
Figure space 
Combining grapheme joiner͏
Em space 
Middle dot·
En dash–
Em dash—
Left/right single quotes‘ / ’
Left/right double quotes“ / ”
Left/right guillemets« / »
Bullet•
Left/right single angle quotes‹ / ›

Customization

Custom entities

You may pass an object to add your own character-to-entity mappings, which will be merged with the defaults.

maizzle.config.ts
export default defineConfig({
  html: {
    decodeEntities: {
      '©': '©',
      '': '™',
    },
  },
})

Disabling

You may disable the transformer if you think you don't need it:

maizzle.config.ts
export default defineConfig({
  html: {
    decodeEntities: false,
  },
})

API

ts
import { entities } from '@maizzle/framework'

// Defaults only
const out = entities('hello world')

// Add a custom mapping (merged with defaults)
const custom = entities('© Maizzle', { '©': '©' })

// Disable the transform
const raw = entities('hello world', false)

The first argument is an HTML string. The second is an EntitiesConfigtrue (or omitted) for the built-in map, an object for additional character → entity mappings merged on top of the defaults, or false to disable. Returns the transformed HTML string.