phpHyphenator (http://yellowgreen.de/phphyphenator) can be used to ‘soft hyphenate’ text, akin to newspapers. Words are broken at the end of a line at an appropriate character within the word (usually after a syllable). Here’s a simple plugin to allow use with EE - copy and paste the code into a file ‘pi.hyphenator.php’, then follow the instructions in the code comments.
<?php
// Author: N David Brown
// License: Freely distributable
//
// Description: Plugin for soft hyphenation of text under ExpressionEngine, using phpHyphenator
//
// Usage:
//
// i. Download phpHyphenator latest version from
//
// http://yellowgreen.de/phphyphenator
//
// ii. Extract phpHyphenator to its own directory, then place anywhere within webroot on
// server
//
// iii. Place this file (pi.hyphenator.php) into your ExpressionEngine plugins directory
// (usually webroot/system/plugins)
//
// iv. Modify MY_WEBROOT and MY_PATH_HYPHENATOR accordingly - inline comments explain how
// (see below in $GLOBALS declarations)
//
// iii. Wrap (X)HTML you wish to be soft hyphenated with '{exp:hyphenator}' tags, e.g.
//
// {exp:hyphenator}<div></div>{/exp:hyphenator}
//
// Notes: If you do not set charset UTF-8 in your HTML within a content-type metatag, you should
// uncomment the 'header(...)' line in the code below, since phpHyphenator requires UTF-8
//
//
// For example of phpHyphenator in action, please visit
//
// http://www.buildingfrombelow.org
//
//
// Copyright of N David Brown, Jun 2009. Contact: developerdave _at_ gmail _dot_ com
// replace 'change_me' with path to webroot, e.g. /path/to/public_html, or /path/to/htdocs
$GLOBALS["MY_WEBROOT"] = 'change_me';
// replace 'change_me' with path to php hyphenator directory, relative to webroot
$GLOBALS["MY_PATH_HYPHENATOR"] = $GLOBALS["MY_WEBROOT"].'change_me';
$GLOBALS["path_to_patterns"] = $GLOBALS["MY_PATH_HYPHENATOR"].'/patterns/';
$GLOBALS["dictionary"] = $GLOBALS["MY_PATH_HYPHENATOR"].'/dictionary.txt';
include $GLOBALS["MY_PATH_HYPHENATOR"].'/hyphenation.php';
class Hyphenator
{
var $return_data = "";
function Hyphenator()
{
global $TMPL;
//header('content-type: text/html; charset=utf-8');
$this->return_data = hyphenation($TMPL->tagdata);
}
}
?>
Let me know if you have any problems.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.