Changeset 43c40f0 in github
- Timestamp:
- Feb 15, 2012 8:24:04 AM (15 months ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.8
- Children:
- b138a9b
- Parents:
- 3ed9e80
- File:
-
- 1 edited
-
program/lib/html2text.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/lib/html2text.php
rf359950 r43c40f0 318 318 * Contains URL addresses from links to be rendered in plain text. 319 319 * 320 * @var string$_link_list320 * @var array $_link_list 321 321 * @access private 322 322 * @see _build_link_list() 323 323 */ 324 var $_link_list = ''; 325 326 /** 327 * Number of valid links detected in the text, used for plain text 328 * display (rendered similar to footnotes). 329 * 330 * @var integer $_link_count 331 * @access private 332 * @see _build_link_list() 333 */ 334 var $_link_count = 0; 324 var $_link_list = array(); 335 325 336 326 /** … … 473 463 { 474 464 // Variables used for building the link list 475 $this->_link_count = 0; 476 $this->_link_list = ''; 465 $this->_link_list = array(); 477 466 478 467 $text = trim(stripslashes($this->html)); … … 482 471 483 472 // Add link list 484 if ( !empty($this->_link_list) ) { 485 $text .= "\n\nLinks:\n------\n" . $this->_link_list; 473 if (!empty($this->_link_list)) { 474 $text .= "\n\nLinks:\n------\n"; 475 foreach ($this->_link_list as $idx => $url) { 476 $text .= '[' . ($idx+1) . '] ' . $url . "\n"; 477 } 486 478 } 487 479 … … 564 556 function _build_link_list( $link, $display ) 565 557 { 566 if ( !$this->_do_links )558 if (!$this->_do_links || empty($link)) { 567 559 return $display; 568 569 if ( preg_match('!^(https?://|mailto:)!', $link) ) { 570 $this->_link_count++;571 $this->_link_list .= '[' . $this->_link_count . "] $link\n"; 572 $additional = ' [' . $this->_link_count . ']';573 } elseif ( substr($link, 0, 11) == 'javascript:' ) { 574 // Don't count the link; ignore it 575 $additional = '';576 // what about href="#anchor" ? 577 } else {578 $this->_link_count++;579 $ this->_link_list .= '[' . $this->_link_count . '] ' .$this->url;580 if ( substr($link, 0, 1) != '/') {581 $ this->_link_list.= '/';560 } 561 562 // Ignored link types 563 if (preg_match('!^(javascript|mailto|#):!i', $link)) { 564 return $display; 565 } 566 567 if (preg_match('!^(https?://)!i', $link)) { 568 $url = $link; 569 } 570 else { 571 $url = $this->url; 572 if (substr($link, 0, 1) != '/') { 573 $url .= '/'; 582 574 } 583 $this->_link_list .= "$link\n"; 584 $additional = ' [' . $this->_link_count . ']'; 585 } 586 587 return $display . $additional; 575 $url .= "$link"; 576 } 577 578 if (($index = array_search($url, $this->_link_list)) === false) { 579 $this->_link_list[] = $url; 580 $index = count($this->_link_list); 581 } 582 583 return $display . ' [' . ($index+1) . ']'; 588 584 } 589 585
Note: See TracChangeset
for help on using the changeset viewer.
