EE: widon’t plugin

Shaun Inman created this neat little plugin for Wordpress to eliminate widows from post titles. Don’t know what widows are, apart from the female kind? Mr Inman explains:

In typesetting, a widow is a single word on a line by itself at the end of a paragraph and is considered bad style.

And we don’t like bad style, do we? So I guess that plugin needed porting to ExpressionEngine.

→ Download the Widon’t plugin for EE.

Installation

Unzip and upload the file to your system/plugins folder and you’re ready to roll.

Usage

The best way to use this plugin is with your entry titles, thus:

{exp:widont}{title}{/exp:widont}

This way, the last space in the title will be replaced with a non-breaking space ( ), eliminating the widow.

August 29th 2006 | Add-Ons, ExpressionEngine | 5 comments


Comments

  1. 1 Milo August 29th 2006, 23:19

    Wow, I never knew there was a name for such a thing, but I sure have been annoyed by it for a while. Now that I know what it’s called I feel inspired to implement a similar hack on my own site :)

  2. 2 Nick August 31st 2006, 14:56

    Why not use white-space: nowrap on title headings?

  3. 3 Low August 31st 2006, 15:03

    @Nick: heh, the same question was asked over at Shaun’s site. The point is, we just want the last two words to stick together, not the whole line/title/text. That way the width of your layout (often more important than the height) will be safe.

  4. 4 Dan April 11th 2007, 13:16

    Hi there,

    Great plugin but i’d like to mention a small change to the regular expression that is needed if any of your titles/strings end with any sort of punctuation.

    Instead of |\s+(\w+)$| which matches any whitespace followed by any word character(s) use |\s+(\S+)$| which matches any whitespace followed by any non whitespace (visible) character. This has the benefit of also pairing and ending such as “my entry !!”.

  5. 5 Phil+ April 8th 2009, 05:19

    GREAT Plugin! Thanks so much!!

Leave a comment



Some html (a, em, strong, etc) allowed.
Email won’t be displayed and takes care of your Gravatar.