# posthtml-widows **Repository Path**: mirrors_posthtml/posthtml-widows ## Basic Information - **Project Name**: posthtml-widows - **Description**: Prevent widow words - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-11-18 - **Last Updated**: 2025-09-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README
PostHTML plugin for preventing widow words
[![Version][npm-version-shield]][npm] [![Build][github-ci-shield]][github-ci] [![License][license-shield]][license] [![Downloads][npm-stats-shield]][npm-stats]The quick brown fox
The quick brown fox
The quick brown fox
') .then(result => console.log(result.html)) ``` Result: ```htmlThe quick brown fox
``` ## Attributes The plugin will only handle strings inside elements that have one of the following attributes: - `prevent-widows` - `no-widows` You may also specify custom attributes to use: ```js posthtml([ preventWidows({ attributes: ['fix-widows'] }) ]) .process('The quick brown fox
') ``` ## Options ### `minWords` Type: `number`\ Default: `4` The minimum number of words a string must contain to be processed. ```js posthtml([ preventWidows({ minWords: 3, }) ]) .process('Prevent widow words
') ``` ### `ignore` Type: `Array`\ Default: (array of objects) An array of objects that specify the `start` and `end` delimiters of strings to ignore. Used to avoid processing templating logic or expressions. By default, the following templating delimiters are ignored: - `{{ }}` - Handlebars, Liquid, Nunjucks, Twig, Jinja2, Mustache - `{% %}` - Liquid, Nunjucks, Twig, Jinja2 - `<%= %>` - EJS, ERB - `<% %>` - EJS, ERB - `{$ }` - Smarty - `` - PHP - `= ?>` - PHP - `#{ }` - Pug You may add custom delimiters to ignore: ```js posthtml([ preventWidows({ ignore: [ { start: '[[', end: ']]' }, // Inside MSO comments { start: '<' }, // ] }) ]) .process( `Using the option to is being tested here.
` ) ``` Result: ```htmlUsing the option to is being tested here.
``` ### `createWidows` Type: `boolean`\ Default: `false` You may also use the plugin to do the opposite of preventing widow words by replacing the ` ` between the last two words with a regular space. ```js posthtml([ preventWidows({ attributes: ['create-widows'], createWidows: true, }) ]) .process('The quick brown fox
') ``` Result: ```htmlThe quick brown fox
``` ## License [MIT](./LICENSE) [npm]: https://www.npmjs.com/package/posthtml-widows [npm-version-shield]: https://img.shields.io/npm/v/posthtml-widows.svg [npm-stats]: http://npm-stat.com/charts.html?package=posthtml-widows [npm-stats-shield]: https://img.shields.io/npm/dt/posthtml-widows.svg [github-ci]: https://github.com/posthtml/posthtml-widows/actions/workflows/nodejs.yml [github-ci-shield]: https://github.com/posthtml/posthtml-widows/actions/workflows/nodejs.yml/badge.svg [license]: ./LICENSE [license-shield]: https://img.shields.io/npm/l/posthtml-widows.svg