Prevent Widow Words

Add a prevent-widows attribute on any HTML tag and the last space in every text node inside it will be replaced with a  .

<extends src="src/layouts/main.html">
  <block name="template">
    <div prevent-widows>
      <p>The quick brown fox jumped over the lazy dog.</p>

That will output:

  <p>The quick brown fox jumped over the lazy&nbsp;dog.</p>

Enable globally

Enable prevent-widows globally by adding it to your Layout's <body> tag.

<!DOCTYPE html>
  <body prevent-widows>
    <block name="template"></block>


const {preventWidows} = require('@maizzle/framework')

const html = await preventWidows('html string')

Copyright © 2022 Maizzle Edit this page on GitHub