Zenscope Studio

Widon’t Plugin for Textpattern

The aam_widont plugin is a re-implementation of Shaun Inman’s Widon’t 2.1 for WordPress as a Textpattern plugin. It prevents typographical widows—words that appear all by themselves on the last line of a paragraph or title.

Widows make text look unbalanced and awkward, which is why they’re usually avoided in professionally-typeset print works. This plugin, like its WordPress sibling, brings the typographical convention of widow-suppression to the Web.

Download aam_widont-0.1.txt (7.6KB, 45 downloads)

UPDATE (6/10/2007): The aam_widont plugin has been replaced by the aam_typogrify plugin, which includes the same widow-prevention feature and a whole lot more. Check it out!

This is my first Textpattern plugin, so feedback is definitely welcome. If you have problems with aam_widont, please report them in the plugin’s support thread on the Textpattern forum.

Usage

Wrap any text or Textpattern template tags in <txp:aam_widont></txp:aam_widont> to prevent widowed words:

Used With a Textpattern Template Tag

To suppress widows in an article excerpt:

<txp:aam_widont>
  <txp:excerpt />
</txp:aam_widont>

Used With Static (X)HTML

You can also use Widon’t in page templates or Textpattern forms, to prevent widows in blocks of static text:

<txp:aam_widont>
  <p>Here's some text that doesn't come from a template tag.</p>
</txp:aam_widont>

License

This plugin is provided under the terms of the BSD license.

Credits and Thanks

These people helped aam_widont happen:

Comments (6 so far)

  1. Superb, thanks so much. Now, how about a port of Typogrify? Perhaps this is something that needs to be built into Textile?

    by Charles Roper on Jun 4, 12:22 pm

  2. Hey Adam, TXP has had this built in pre-4.0.4 (r1783UTF-8 update). It’d probably be best to send a patch instead of a plugin.

    by JM on Jun 4, 05:27 pm

  3. I was about to write the same thing as JM – This is already in Textpattern, via: Admin > Preferences > Advanced. There is a radio button toggle labeled: Prevent widowed words in article titles. So, no plugin or patch needed. :)

    That being said, I think it’s dedicated people who write plugins that make TXP so great. I certainly don’t want to discourage you from writing more plugins in the future.

    by Nathan Smith on Jun 5, 10:53 am

  4. Oops, I read to hastily. I didn’t realize your plugin handles widows for paragraphs too. Very nice!

    by Nathan Smith on Jun 5, 10:54 am

  5. Charles Roper said:

    Superb, thanks so much. Now, how about a port of Typogrify? Perhaps this is something that needs to be built into Textile?

    I see a lot to like in Typogrify, but I wonder about the performance implications of running that many regexes on a page that’s served dynamically. Yeah, I know there’s a WordPress plugin. If every other CMS jumped off a bridge, would you jump off too? ;-)

    Including some of Typogrify’s features in Textile might be a good idea. One of the reasons for Textpattern’s speed is that Textile processing isn’t done when the page is requested. It’s performed when the page is saved, and the HTML code is stored in the database along with the original text. Plugins like this one, however, get processed when the page is rendered. I don’t think there’s a way to perform that kind of pre-processing with a plugin unless you edit core files.

    If all the typographical goodies of Typogrify do get added to Textpattern, I hope that there are configuration options to turn some of them off. I’ll probably never use things like the class for ampersands, and I’d rather not have unused elements cluttering up my code. I’m already annoyed that I can’t keep Textile from wrapping strings of capital letters in a span tag.

    JM said:

    Hey Adam, TXP has had this built in pre-4.0.4 (r1783 – UTF-8 update). It’d probably be best to send a patch instead of a plugin.

    I already started a thread in the Textpattern forum, suggesting that widow prevention with the no_widow attribute be available on all template tags. Response from one of the developers was pretty lukewarm; Mary observed, correctly, that it could very easily be implemented as a plugin. It seemed like a good “my first plugin” project, so went ahead and did it.

    There’s an admirable commitment on the part of the core Textpattern developers to keeping the system lean and mean. That means you may not get every feature you’d hope for built into the system, but it’s also contributed to the thriving plugin development community.

    Nathan Smith wrote:

    I didn’t realize your plugin handles widows for paragraphs too. Very nice!

    Yep! Static text in page templates and output from template tags other than txp:title is what I was going for here. Getting widow prevention for custom fields was especially important for me. When I use an article list for navigation, I’ll sometimes shorten the article titles and use a custom field with a longer “title” as the main page heading. I just used this strategy on a client’s site, which is what inspired the idea.

    by Adam Messinger on Jun 8, 01:07 am

  6. Even in custom fields! Very cool! I’ll definitely keep this in mind for one of my next projects.
    Thanks a lot!

    by uli on Jun 8, 03:06 pm

Comments are closed for this article.