---
title: "Soft Hyphenator"
date: 2010-02-14
url: https://fortes.com/2010/soft-hyphenator/
summary: "Automatically stuffing soft hyphens into HTML so justified text behaves better"
---

I'm happy to announce [Soft Hyphenator](https://github.com/fortes/softhyphen), a simple utility I wrote this weekend that adds [soft hyphens](http://en.wikipedia.org/wiki/Hyphen#Hyphens_in_computing) into HTML content.

Today's web browsers don't provide hyphenation, which makes justified text prone to [rivers of white space](http://www.fonts.com/AboutFonts/Articles/fyti/JustifiedType.htm). However, browsers do support the soft-hyphen: the `&shy;` HTML entity. Soft hyphens tell the browser where it can break a word, if necessary.

Adding these hyphens manually is quite tedious. The Soft Hyphenator takes HTML and adds the soft hyphens automatically.

The site is written in Python and deployed on Google AppEngine. It uses the BeautifulSoup and python-hyphenator libraries, along with [OpenOffice's hyphenation dictionaries](http://wiki.services.openoffice.org/wiki/Dictionaries). For the nerdy &amp; curious, I've made the [source code](https://github.com/fortes/softhyphen) public.

I'm still quite new to Python and Google AppEngine, but I'm pretty happy with both so far. The entire site took less than 24 hours to write, and the [WTF/minute](http://www.osnews.com/story/19266/WTFs_m) rate was pretty good.

