Changeset 2317 in subversion
- Timestamp:
- Feb 27, 2009 5:56:45 AM (4 years ago)
- File:
-
- 1 edited
-
trunk/roundcubemail/program/lib/html2text.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/program/lib/html2text.php
r2248 r2317 202 202 "\t* \\1\n", // <li> and </li> 203 203 "\n\t* ", // <li> 204 "\n-------------------------\n", // <hr>205 "\n\n", // <table> and </table>204 "\n-------------------------\n", // <hr> 205 "\n\n", // <table> and </table> 206 206 "\n", // <tr> and </tr> 207 207 "\t\t\\1\n", // <td> and </td> … … 248 248 */ 249 249 var $pre_search = array( 250 "/\n/",251 "/\t/",252 '/ /',253 '/<pre[^>]*>/',254 '/<\/pre>/'250 "/\n/", 251 "/\t/", 252 '/ /', 253 '/<pre[^>]*>/', 254 '/<\/pre>/' 255 255 ); 256 256 … … 263 263 */ 264 264 var $pre_replace = array( 265 '<br>',266 ' ',267 ' ',268 '',269 ''265 '<br>', 266 ' ', 267 ' ', 268 '', 269 '' 270 270 ); 271 271 … … 343 343 $this->set_html($source, $from_file); 344 344 } 345 345 346 346 $this->set_base_url(); 347 $this->_do_links = $do_links;348 $this->width = $width;347 $this->_do_links = $do_links; 348 $this->width = $width; 349 349 } 350 350 … … 360 360 { 361 361 if ( $from_file && file_exists($source) ) { 362 $this->html = file_get_contents($source);362 $this->html = file_get_contents($source); 363 363 } 364 364 else 365 $this->html = $source;365 $this->html = $source; 366 366 367 367 $this->_converted = false; … … 464 464 $text = trim(stripslashes($this->html)); 465 465 466 // Convert <PRE>466 // Convert <PRE> 467 467 $this->_convert_pre($text); 468 468 … … 471 471 $text = preg_replace_callback($this->callback_search, array('html2text', '_preg_callback'), $text); 472 472 473 // Replace known html entities474 $text = html_entity_decode($text, ENT_COMPAT, 'UTF-8');473 // Replace known html entities 474 $text = html_entity_decode($text, ENT_COMPAT, 'UTF-8'); 475 475 476 476 // Remove unknown/unhandled entities (this cannot be done in search-and-replace block) … … 548 548 function _convert_pre(&$text) 549 549 { 550 while(preg_match('/<pre[^>]*>(.*)<\/pre>/ismU', $text, $matches)) 551 { 552 $result = preg_replace($this->pre_search, $this->pre_replace, $matches[1]); 553 $text = preg_replace('/<pre[^>]*>.*<\/pre>/ismU', '<div><br>' . $result . '<br></div>', $text, 1); 554 } 550 while(preg_match('/<pre[^>]*>(.*)<\/pre>/ismU', $text, $matches)) { 551 $result = preg_replace($this->pre_search, $this->pre_replace, $matches[1]); 552 $text = preg_replace('/<pre[^>]*>.*<\/pre>/ismU', '<div><br>' . $result . '<br></div>', $text, 1); 553 } 555 554 } 556 555 … … 564 563 function _preg_callback($matches) 565 564 { 566 switch($matches[1]) 567 { 568 case 'b': 569 case 'strong': 570 return $this->_strtoupper($matches[2]); 571 case 'hr': 572 return $this->_strtoupper("\t\t". $matches[2] ."\n"); 573 case 'h': 574 return $this->_strtoupper("\n\n". $matches[2] ."\n\n"); 575 case 'a': 576 return $this->_build_link_list($matches[3], $matches[4]); 577 } 565 switch($matches[1]) { 566 case 'b': 567 case 'strong': 568 return $this->_strtoupper($matches[2]); 569 case 'hr': 570 return $this->_strtoupper("\t\t". $matches[2] ."\n"); 571 case 'h': 572 return $this->_strtoupper("\n\n". $matches[2] ."\n\n"); 573 case 'a': 574 return $this->_build_link_list($matches[3], $matches[4]); 575 } 578 576 } 579 577 … … 587 585 function _strtoupper($str) 588 586 { 589 if (function_exists('mb_strtoupper'))590 return mb_strtoupper($str);591 else592 return strtoupper($str);587 if (function_exists('mb_strtoupper')) 588 return mb_strtoupper($str); 589 else 590 return strtoupper($str); 593 591 } 594 592 }
Note: See TracChangeset
for help on using the changeset viewer.
