1<?php 2/** 3 * Hyphenation Action Plugin 4 * Uses phpHyphenation from http://yellowgreen.de/hyphenation-in-web/ 5 * 6 * @license GPLv3 (http://www.gnu.org/licenses/gpl.html) 7 * @link http://www.dokuwiki.org/plugin:hyphenation 8 * @author Markus Birth <markus@birth-online.de> 9 */ 10 11if(!defined('DOKU_INC')) die(); 12if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 13require_once(DOKU_PLUGIN.'action.php'); 14include_once(dirname(__FILE__).'/phpHyphenation/phpHyphenation.class.php'); 15 16class action_plugin_hyphenation extends DokuWiki_Action_Plugin { 17 18 function getInfo(){ 19 return confToHash(dirname(__FILE__).'/INFO.txt'); 20 } 21 22 function register(&$controller) { 23 $controller->register_hook('RENDERER_CONTENT_POSTPROCESS', 'BEFORE', $this, '_dohyph'); 24 } 25 26 function _dohyph(&$event, $param) { 27 if ($event->data[0] != 'xhtml') return; // do nothing if not xhtml (we don't want to hyphenate ODT or PDF) 28 $phpHyphPath = dirname(__FILE__).'/phpHyphenation'; 29 30 $html = &$event->data[1]; 31 phpHyphenation::setPatternPath($phpHyphPath . '/patterns/'); 32 $hyph = new phpHyphenation($this->getConf('language')); 33 if ($hyph === false) return; 34 $hyph->loadUserDictFromArray(explode("\n", $this->getConf('customhyph'))); 35 36 $html = $hyph->doHyphenation($html); 37 } 38 39}