{
$this->_indent = 0;
$this->_linkList = array();
+ $this->_params['_bq'] = false;
return $text;
}
try {
$dom = new Horde_Domhtml($text, $this->_params['charset']);
$text = Horde_String::convertCharset($this->_node($dom->dom, $dom->dom), null, $this->_params['charset']);
+ $dom_convert = true;
} catch (Exception $e) {
$text = strip_tags(preg_replace("/\<br\s*\/?\>/i", "\n", $text));
+ $dom_convert = false;
}
/* Bring down number of empty lines to 2 max, and remove trailing
/* Wrap the text to a readable format. */
if ($this->_params['width']) {
- $text = wordwrap($text, $this->_params['width']);
+ if ($dom_convert &&
+ $this->_params['_bq'] &&
+ class_exists('Horde_Text_Flowed')) {
+ $flowed = new Horde_Text_Flowed($text, $this->_params['charset']);
+ $flowed->setOptLength($this->_params['width']);
+ $text = $flowed->toFlowed();
+ } else {
+ $text = wordwrap($text, $this->_params['width']);
+ }
}
/* Add link list. */
break;
case 'blockquote':
+ $this->_params['_bq'] = true;
foreach (explode("\n", $this->_node($doc, $child)) as $line) {
$quote = '>';
- if (($line[0] != '>') &&
+ if ($line &&
+ ($line[0] != '>') &&
($line[0] != ' ' || $line[0] != "\t")) {
$quote .= ' ';
}
<api>beta</api>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes> * Add callback parameter to the Html2text filter.
+ <notes>* Html2text filter will use horde/Text_Filter, if available, to wrap text.
+ * Add callback parameter to the Html2text filter.
* XSS filter now uses PHP DOM parser to process incoming text.
* Remove Horde/Core dependency.
* Add Horde_Text_Filter_Exception::.
<name>Text_Filter_Csstidy</name>
<channel>pear.horde.org</channel>
</package>
+ <package>
+ <name>Text_Flowed</name>
+ <channel>pear.horde.org</channel>
+ </package>
<extension>
<name>dom</name>
</extension>