Quantcast
Channel: Planet Plone - Where Developers And Integrators Write
Viewing all articles
Browse latest Browse all 3535

Mock It!: Python, long words and the soft hyphen

$
0
0
The HTML specification (any of them) does not require or allow a user agent to manage text hyphenation. Instead, it must rely on hints provided by the document:
The soft hyphen tells the user agent where a line break can occur.
In English, (very) long words are relatively infrequent, and as such, hyphenation is not particularly important. The lack of good hyphenation rarely breaks a page layout.

In German – and in Germanic languages in general – words are long! If you have a page layout with narrow columns (a left-hand side navigation for instance), lines might extend further than you'd like them to.

The following Python function inserts soft hyphens into a text string, guided by a hyphenation dictionary:

If you can't see the script embedded above, you can see the source here.

Viewing all articles
Browse latest Browse all 3535

Trending Articles