Changeset 7353fab in github
- Timestamp:
- Aug 29, 2008 4:40:21 AM (5 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- 7789fdd
- Parents:
- 7f9d71b
- File:
-
- 1 edited
-
program/lib/html2text.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/lib/html2text.php
rff73e02 r7353fab 32 32 *************************************************************************/ 33 33 34 /* 2008/08/29: Added PRE handling by A.L.E.C <alec@alec.pl> */ 34 35 35 36 /** … … 200 201 201 202 /** 203 * List of preg* regular expression patterns to search for in PRE body, 204 * used in conjunction with $pre_replace. 205 * 206 * @var array $pre_search 207 * @access public 208 * @see $pre_replace 209 */ 210 $pre_search = array( 211 "/\n/", 212 "/\t/", 213 '/ /', 214 '/<pre[^>]*>/', 215 '/<\/pre>/' 216 ); 217 218 /** 219 * List of pattern replacements corresponding to patterns searched for PRE body. 220 * 221 * @var array $pre_replace 222 * @access public 223 * @see $pre_search 224 */ 225 $pre_replace = array( 226 '<br>', 227 ' ', 228 ' ', 229 '', 230 '' 231 ); 232 233 /** 202 234 * Contains a list of HTML tags to allow in the resulting text. 203 235 * … … 376 408 $text = trim(stripslashes($this->html)); 377 409 410 // Convert <PRE> 411 $this->_convert_pre($text); 412 378 413 // Run our defined search-and-replace 379 414 $text = preg_replace($this->search, $this->replace, $text); … … 445 480 return $display . ' [' . ($index+1) . ']'; 446 481 } 482 483 /** 484 * Helper function for PRE body conversion. 485 * 486 * @param string HTML content 487 * @access private 488 */ 489 function _convert_pre(&$text) 490 { 491 while(preg_match('/<pre[^>]*>(.*)<\/pre>/ismU', $text, $matches)) 492 { 493 $result = preg_replace($this->pre_search, $this->pre_replace, $matches[1]); 494 $text = preg_replace('/<pre[^>]*>.*<\/pre>/ismU', '<div><br>' . $result . '<br></div>', $text); 495 } 496 } 447 497 } 448 498
Note: See TracChangeset
for help on using the changeset viewer.
