Prevent widow words
Add aprevent-widows attribute on any HTML tag to prevent widow words by adding a between the last two words inside it.
emails/example.html
prevent-widows attribute will be removed and the HTML will be transformed to:
Configuration
You may configure the transformer through thewidowWords key in your config.js:
config.js
attrName
A list of attribute names that will trigger the transformer.
minWords
The minimum amount of words in a target string, in order to trigger the transformer.
0 or false to disable it.
createWidows
Set this to
true if you want the opposite of preventing widow words: it will replace all widow word nbsp; locations with a single space.ignore
Start/end pairs of strings that will prevent the transformer from removing widow words inside of them.
{{ }}- Handlebars, Liquid, Nunjucks, Twig, Jinja2, Mustache{% %}- Liquid, Nunjucks, Twig, Jinja2<%= %>- EJS, ERB<% %>- EJS, ERB{$ }- Smarty<?php ?>- PHP<?= ?>- PHP#{ }- Pug
config.js
Undo widows
You can use the transformer the other way around, too.config.js
emails/example.html
emails/example.html
API
app.js