UNPKG

@maizzle/framework

Version:

Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.

52 lines (51 loc) 1.97 kB
import { EntitiesConfig } from "../types/config.js"; import { ChildNode } from "domhandler"; //#region src/transformers/entities.d.ts /** * Node types {@link entitiesDom} encodes. Both default to `true`. */ interface EntitiesScope { /** Encode entities in text nodes */ text?: boolean; /** * Encode entities in comment nodes. MSO conditional comment content is * rendered by Outlook, and comment data survives parse round-trips * un-decoded — so encoding here protects whitespace-only conditionals * (e.g. `<Outlook>&nbsp;</Outlook>` spacers) from being collapsed * or removed by email-comb and html-crush downstream. */ comments?: boolean; } /** * Replace literal Unicode characters in text and comment nodes with their * HTML entity equivalents (zero-width joiners, non-breaking spaces, smart * quotes, dashes, etc.) for better email-client rendering. * * @param html HTML string to transform. * @param custom Extra entries merged on top of the built-in entity map, or * `false` to disable the transform. Defaults to `true` * (built-ins only). * @returns The transformed HTML string. * * @example * import { entities } from '@maizzle/framework' * * // Defaults only * entities('hello world') // → 'hello&nbsp;world' * * // Add a custom mapping * entities('© Maizzle', { '©': '&copy;' }) * * // Disable the transform * entities('hello world', false) */ declare function entities(html: string, custom?: EntitiesConfig, scope?: EntitiesScope): string; /** * DOM-form of {@link entities} used by the internal transformer pipeline. * Takes a parsed DOM, returns a parsed DOM — avoids redundant * serialize/parse round-trips when chained with other transformers. */ declare function entitiesDom(dom: ChildNode[], custom?: EntitiesConfig, scope?: EntitiesScope): ChildNode[]; //#endregion export { EntitiesScope, entities, entitiesDom }; //# sourceMappingURL=entities.d.ts.map