This plugin replaces escaped characters in class names from your
<style> tags and inside
class="" attributes with safe characters, that do not need escaping.
By default, it replaces:
Because I needed a way to use Tailwind CSS variants in my HTML emails 🤷♂️
Escaped characters in CSS selectors or HTML class names are not supported by all email clients (currently Gmail being the biggest one), so you can use this plugin to replace them with safe alternatives.
$ npm i posthtml posthtml-safe-class-names
const fs =const posthtml =const safeClassNames =const source = fs
The plugin accepts an options object where you can define character replacement mappings.
':': '-''\/': '-''%': 'pc''.': '_'
Besides adding new mappings, you can of course override the default ones.
Using the same
example.html, let's choose to replace
\: in our class names with
__ instead of