From c773c80c0f913f4bbba654c54bf02d22f9ede51c Mon Sep 17 00:00:00 2001 From: Michael Tibben Date: Thu, 26 Dec 2013 15:14:18 +1100 Subject: [PATCH 1/3] Bump composer dependencies --- composer.lock | 179 ++++++++++++++++++++++++++++---------------------- 1 file changed, 101 insertions(+), 78 deletions(-) diff --git a/composer.lock b/composer.lock index 31a1e56..40bddb0 100644 --- a/composer.lock +++ b/composer.lock @@ -1,36 +1,46 @@ { - "hash": "36749d23e6f948ca0eeec81f559bf10e", + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" + ], + "hash": "07cc1d32ce90d61d6035c77c29ee2e65", "packages": [ ], "packages-dev": [ { "name": "phpunit/php-code-coverage", - "version": "1.2.7", + "version": "1.2.13", "source": { "type": "git", - "url": "git://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "1.2.7" + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "466e7cd2554b4e264c9e3f31216d25ac0e5f3d94" }, "dist": { "type": "zip", - "url": "https://github.com/sebastianbergmann/php-code-coverage/archive/1.2.7.zip", - "reference": "1.2.7", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/466e7cd2554b4e264c9e3f31216d25ac0e5f3d94", + "reference": "466e7cd2554b4e264c9e3f31216d25ac0e5f3d94", "shasum": "" }, "require": { "php": ">=5.3.3", "phpunit/php-file-iterator": ">=1.3.0@stable", - "phpunit/php-token-stream": ">=1.1.3@stable", - "phpunit/php-text-template": ">=1.1.1@stable" + "phpunit/php-text-template": ">=1.1.1@stable", + "phpunit/php-token-stream": ">=1.1.3@stable" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*@dev" }, "suggest": { "ext-dom": "*", "ext-xdebug": ">=2.0.5" }, - "time": "2012-12-02 14:54:55", "type": "library", - "installation-source": "dist", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, "autoload": { "classmap": [ "PHP/" @@ -53,31 +63,30 @@ "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", "homepage": "https://github.com/sebastianbergmann/php-code-coverage", "keywords": [ - "testing", "coverage", + "testing", "xunit" - ] + ], + "time": "2013-09-10 08:14:32" }, { "name": "phpunit/php-file-iterator", - "version": "1.3.3", + "version": "1.3.4", "source": { "type": "git", - "url": "git://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "1.3.3" + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" }, "dist": { "type": "zip", - "url": "https://github.com/sebastianbergmann/php-file-iterator/zipball/1.3.3", - "reference": "1.3.3", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2012-10-11 04:44:38", "type": "library", - "installation-source": "dist", "autoload": { "classmap": [ "File/" @@ -98,11 +107,12 @@ } ], "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "http://www.phpunit.de/", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", "keywords": [ "filesystem", "iterator" - ] + ], + "time": "2013-10-10 15:34:57" }, { "name": "phpunit/php-text-template", @@ -121,9 +131,7 @@ "require": { "php": ">=5.3.3" }, - "time": "2012-10-31 11:15:28", "type": "library", - "installation-source": "dist", "autoload": { "classmap": [ "Text/" @@ -147,28 +155,27 @@ "homepage": "https://github.com/sebastianbergmann/php-text-template/", "keywords": [ "template" - ] + ], + "time": "2012-10-31 11:15:28" }, { "name": "phpunit/php-timer", - "version": "1.0.4", + "version": "1.0.5", "source": { "type": "git", - "url": "git://github.com/sebastianbergmann/php-timer.git", - "reference": "1.0.4" + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" }, "dist": { "type": "zip", - "url": "https://github.com/sebastianbergmann/php-timer/zipball/1.0.4", - "reference": "1.0.4", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2012-10-11 04:45:58", "type": "library", - "installation-source": "dist", "autoload": { "classmap": [ "PHP/" @@ -189,32 +196,36 @@ } ], "description": "Utility class for timing", - "homepage": "http://www.phpunit.de/", + "homepage": "https://github.com/sebastianbergmann/php-timer/", "keywords": [ "timer" - ] + ], + "time": "2013-08-02 07:42:54" }, { "name": "phpunit/php-token-stream", - "version": "1.1.5", + "version": "1.2.1", "source": { "type": "git", - "url": "git://github.com/sebastianbergmann/php-token-stream.git", - "reference": "1.1.5" + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "5220af2a7929aa35cf663d97c89ad3d50cf5fa3e" }, "dist": { "type": "zip", - "url": "https://github.com/sebastianbergmann/php-token-stream/zipball/1.1.5", - "reference": "1.1.5", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/5220af2a7929aa35cf663d97c89ad3d50cf5fa3e", + "reference": "5220af2a7929aa35cf663d97c89ad3d50cf5fa3e", "shasum": "" }, "require": { "ext-tokenizer": "*", "php": ">=5.3.3" }, - "time": "2012-10-11 04:47:14", "type": "library", - "installation-source": "dist", + "extra": { + "branch-alias": { + "dev-master": "1.2-dev" + } + }, "autoload": { "classmap": [ "PHP/" @@ -235,45 +246,48 @@ } ], "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "http://www.phpunit.de/", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", "keywords": [ "tokenizer" - ] + ], + "time": "2013-09-13 04:58:23" }, { "name": "phpunit/phpunit", - "version": "3.7.10", + "version": "3.7.28", "source": { "type": "git", - "url": "git://github.com/sebastianbergmann/phpunit.git", - "reference": "3.7.10" + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "3b97c8492bcafbabe6b6fbd2ab35f2f04d932a8d" }, "dist": { "type": "zip", - "url": "https://github.com/sebastianbergmann/phpunit/archive/3.7.10.zip", - "reference": "3.7.10", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3b97c8492bcafbabe6b6fbd2ab35f2f04d932a8d", + "reference": "3b97c8492bcafbabe6b6fbd2ab35f2f04d932a8d", "shasum": "" }, "require": { - "php": ">=5.3.3", - "phpunit/php-file-iterator": ">=1.3.1", - "phpunit/php-text-template": ">=1.1.1", - "phpunit/php-code-coverage": ">=1.2.1", - "phpunit/php-timer": ">=1.0.2", - "phpunit/phpunit-mock-objects": ">=1.2.0,<1.3.0", - "symfony/yaml": ">=2.1.0", "ext-dom": "*", "ext-pcre": "*", "ext-reflection": "*", - "ext-spl": "*" + "ext-spl": "*", + "php": ">=5.3.3", + "phpunit/php-code-coverage": "~1.2.1", + "phpunit/php-file-iterator": ">=1.3.1", + "phpunit/php-text-template": ">=1.1.1", + "phpunit/php-timer": ">=1.0.4", + "phpunit/phpunit-mock-objects": "~1.2.0", + "symfony/yaml": "~2.0" + }, + "require-dev": { + "pear-pear/pear": "1.9.4" }, "suggest": { - "phpunit/php-invoker": ">=1.1.0", "ext-json": "*", "ext-simplexml": "*", - "ext-tokenizer": "*" + "ext-tokenizer": "*", + "phpunit/php-invoker": ">=1.1.0,<1.2.0" }, - "time": "2012-12-02 14:56:55", "bin": [ "composer/bin/phpunit" ], @@ -283,7 +297,6 @@ "dev-master": "3.7.x-dev" } }, - "installation-source": "dist", "autoload": { "classmap": [ "PHPUnit/" @@ -307,23 +320,24 @@ "description": "The PHP Unit Testing framework.", "homepage": "http://www.phpunit.de/", "keywords": [ - "testing", "phpunit", + "testing", "xunit" - ] + ], + "time": "2013-10-17 07:27:40" }, { "name": "phpunit/phpunit-mock-objects", - "version": "1.2.2", + "version": "1.2.3", "source": { "type": "git", - "url": "git://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "1.2.2" + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875" }, "dist": { "type": "zip", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects/archive/1.2.2.zip", - "reference": "1.2.2", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5794e3c5c5ba0fb037b11d8151add2a07fa82875", + "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875", "shasum": "" }, "require": { @@ -333,9 +347,7 @@ "suggest": { "ext-soap": "*" }, - "time": "2012-11-05 10:39:13", "type": "library", - "installation-source": "dist", "autoload": { "classmap": [ "PHPUnit/" @@ -360,32 +372,36 @@ "keywords": [ "mock", "xunit" - ] + ], + "time": "2013-01-13 10:24:48" }, { "name": "symfony/yaml", - "version": "v2.1.5", + "version": "v2.4.0", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", - "url": "https://github.com/symfony/Yaml", - "reference": "v2.1.5" + "url": "https://github.com/symfony/Yaml.git", + "reference": "1ae235a1b9d3ad3d9f3860ff20acc072df95b7f5" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/Yaml/archive/v2.1.5.zip", - "reference": "v2.1.5", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/1ae235a1b9d3ad3d9f3860ff20acc072df95b7f5", + "reference": "1ae235a1b9d3ad3d9f3860ff20acc072df95b7f5", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2012-12-06 10:00:55", "type": "library", - "installation-source": "dist", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, "autoload": { "psr-0": { - "Symfony\\Component\\Yaml": "" + "Symfony\\Component\\Yaml\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -403,7 +419,8 @@ } ], "description": "Symfony Yaml Component", - "homepage": "http://symfony.com" + "homepage": "http://symfony.com", + "time": "2013-11-26 16:40:27" } ], "aliases": [ @@ -412,5 +429,11 @@ "minimum-stability": "stable", "stability-flags": [ + ], + "platform": [ + + ], + "platform-dev": [ + ] } From f4b0b5fec4267c332683cab22b97a271cf8f888f Mon Sep 17 00:00:00 2001 From: Michael Tibben Date: Thu, 26 Dec 2013 15:14:44 +1100 Subject: [PATCH 2/3] Add php 5.5 to travis --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 02bf324..2d9c979 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,5 +2,6 @@ language: php php: - 5.3 - 5.4 + - 5.5 before_script: - - composer install --dev + - composer install From cd99edb2ee08f5becd8a0234749fe52a0456506d Mon Sep 17 00:00:00 2001 From: Michael Tibben Date: Thu, 10 Oct 2013 15:17:33 +1100 Subject: [PATCH 3/3] Clean up code formatting --- lib/Html2Text/Html2Text.php | 305 ++++++++++++++++-------------------- 1 file changed, 135 insertions(+), 170 deletions(-) diff --git a/lib/Html2Text/Html2Text.php b/lib/Html2Text/Html2Text.php index af59e84..9b26ebe 100644 --- a/lib/Html2Text/Html2Text.php +++ b/lib/Html2Text/Html2Text.php @@ -22,45 +22,43 @@ namespace Html2Text; +/** + * Converts HTML to formatted plain text + */ class Html2Text { - /** - * Contains the HTML content to convert. + * Contains the HTML content to convert. * - * @var string $html - * @access public + * @var string $html */ - public $html; + protected $html; /** - * Contains the converted, formatted text. + * Contains the converted, formatted text. * - * @var string $text - * @access public + * @var string $text */ - public $text; + protected $text; /** - * Maximum width of the formatted text, in columns. + * Maximum width of the formatted text, in columns. * - * Set this value to 0 (or less) to ignore word wrapping - * and not constrain text to a fixed-width column. + * Set this value to 0 (or less) to ignore word wrapping + * and not constrain text to a fixed-width column. * - * @var integer $width - * @access public + * @var integer $width */ - public $width = 70; + protected $width = 70; /** - * List of preg* regular expression patterns to search for, - * used in conjunction with $replace. + * List of preg* regular expression patterns to search for, + * used in conjunction with $replace. * - * @var array $search - * @access public - * @see $replace + * @var array $search + * @see $replace */ - public $search = array( + protected $search = array( "/\r/", // Non-legal carriage return "/[\n\t]+/", // Newlines and tabs '/]*>.*?<\/head>/i', // @@ -86,13 +84,12 @@ class Html2Text ); /** - * List of pattern replacements corresponding to patterns searched. + * List of pattern replacements corresponding to patterns searched. * - * @var array $replace - * @access public - * @see $search + * @var array $replace + * @see $search */ - public $replace = array( + protected $replace = array( '', // Non-legal carriage return ' ', // Newlines and tabs '', // @@ -118,17 +115,16 @@ class Html2Text ); /** - * List of preg* regular expression patterns to search for, - * used in conjunction with $ent_replace. + * List of preg* regular expression patterns to search for, + * used in conjunction with $ent_replace. * - * @var array $ent_search - * @access public - * @see $ent_replace + * @var array $ent_search + * @see $ent_replace */ - public $ent_search = array( + protected $ent_search = array( '/&(nbsp|#160);/i', // Non-breaking space '/&(quot|rdquo|ldquo|#8220|#8221|#147|#148);/i', - // Double quotes + // Double quotes '/&(apos|rsquo|lsquo|#8216|#8217);/i', // Single quotes '/>/i', // Greater-than '/</i', // Less-than @@ -145,13 +141,12 @@ class Html2Text ); /** - * List of pattern replacements corresponding to patterns searched. + * List of pattern replacements corresponding to patterns searched. * - * @var array $ent_replace - * @access public - * @see $ent_search + * @var array $ent_replace + * @see $ent_search */ - public $ent_replace = array( + protected $ent_replace = array( ' ', // Non-breaking space '"', // Double quotes "'", // Single quotes @@ -170,29 +165,27 @@ class Html2Text ); /** - * List of preg* regular expression patterns to search for - * and replace using callback function. + * List of preg* regular expression patterns to search for + * and replace using callback function. * - * @var array $callback_search - * @access public + * @var array $callback_search */ - public $callback_search = array( + protected $callback_search = array( '/<(a) [^>]*href=("|\')([^"\']+)\2([^>]*)>(.*?)<\/a>/i', // - '/<(h)[123456]( [^>]*)?>(.*?)<\/h[123456]>/i', // h1 - h6 - '/<(b)( [^>]*)?>(.*?)<\/b>/i', // - '/<(strong)( [^>]*)?>(.*?)<\/strong>/i', // - '/<(th)( [^>]*)?>(.*?)<\/th>/i', // and + '/<(h)[123456]( [^>]*)?>(.*?)<\/h[123456]>/i', // h1 - h6 + '/<(b)( [^>]*)?>(.*?)<\/b>/i', // + '/<(strong)( [^>]*)?>(.*?)<\/strong>/i', // + '/<(th)( [^>]*)?>(.*?)<\/th>/i', // and ); /** - * List of preg* regular expression patterns to search for in PRE body, - * used in conjunction with $pre_replace. + * List of preg* regular expression patterns to search for in PRE body, + * used in conjunction with $pre_replace. * - * @var array $pre_search - * @access public - * @see $pre_replace + * @var array $pre_search + * @see $pre_replace */ - public $pre_search = array( + protected $pre_search = array( "/\n/", "/\t/", '/ /', @@ -201,13 +194,12 @@ class Html2Text ); /** - * List of pattern replacements corresponding to patterns searched for PRE body. + * List of pattern replacements corresponding to patterns searched for PRE body. * - * @var array $pre_replace - * @access public - * @see $pre_search + * @var array $pre_replace + * @see $pre_search */ - public $pre_replace = array( + protected $pre_replace = array( '
', '    ', ' ', @@ -216,47 +208,42 @@ class Html2Text ); /** - * Contains a list of HTML tags to allow in the resulting text. + * Contains a list of HTML tags to allow in the resulting text. * - * @var string $allowed_tags - * @access public - * @see set_allowed_tags() + * @var string $allowed_tags + * @see set_allowed_tags() */ - public $allowed_tags = ''; + protected $allowed_tags = ''; /** - * Contains the base URL that relative links should resolve to. + * Contains the base URL that relative links should resolve to. * - * @var string $url - * @access public + * @var string $url */ - public $url; + protected $url; /** - * Indicates whether content in the $html variable has been converted yet. + * Indicates whether content in the $html variable has been converted yet. * - * @var boolean $_converted - * @access private - * @see $html, $text + * @var boolean $_converted + * @see $html, $text */ - private $_converted = false; + protected $_converted = false; /** - * Contains URL addresses from links to be rendered in plain text. + * Contains URL addresses from links to be rendered in plain text. * - * @var array $_link_list - * @access private - * @see _build_link_list() + * @var array $_link_list + * @see _build_link_list() */ - private $_link_list = array(); + protected $_link_list = array(); /** - * Various configuration options (able to be set in the constructor) + * Various configuration options (able to be set in the constructor) * - * @var array $_options - * @access private + * @var array $_options */ - private $_options = array( + protected $_options = array( // 'none' // 'inline' (show links inline) @@ -264,30 +251,28 @@ class Html2Text // 'table' (if a table of link URLs should be listed after the text. 'do_links' => 'inline', - // Maximum width of the formatted text, in columns. - // Set this value to 0 (or less) to ignore word wrapping - // and not constrain text to a fixed-width column. + // Maximum width of the formatted text, in columns. + // Set this value to 0 (or less) to ignore word wrapping + // and not constrain text to a fixed-width column. 'width' => 70, ); /** - * Constructor. + * Constructor. * - * If the HTML source string (or file) is supplied, the class - * will instantiate with that source propagated, all that has - * to be done it to call get_text(). + * If the HTML source string (or file) is supplied, the class + * will instantiate with that source propagated, all that has + * to be done it to call get_text(). * - * @param string $source HTML content - * @param boolean $from_file Indicates $source is a file to pull content from - * @param array $options Set configuration options - * @access public - * @return void + * @param string $source HTML content + * @param boolean $from_file Indicates $source is a file to pull content from + * @param array $options Set configuration options */ - public function __construct( $source = '', $from_file = false, $options = array() ) + public function __construct($source = '', $from_file = false, $options = array()) { $this->_options = array_merge($this->_options, $options); - if ( !empty($source) ) { + if (!empty($source)) { $this->set_html($source, $from_file); } @@ -295,28 +280,26 @@ public function __construct( $source = '', $from_file = false, $options = array( } /** - * Loads source HTML into memory, either from $source string or a file. + * Loads source HTML into memory, either from $source string or a file. * - * @param string $source HTML content - * @param boolean $from_file Indicates $source is a file to pull content from - * @access public - * @return void + * @param string $source HTML content + * @param boolean $from_file Indicates $source is a file to pull content from */ - public function set_html( $source, $from_file = false ) + public function set_html($source, $from_file = false) { - if ( $from_file && file_exists($source) ) { + if ($from_file && file_exists($source)) { $this->html = file_get_contents($source); - } else + } else { $this->html = $source; + } $this->_converted = false; } /** - * Returns the text, converted from HTML. + * Returns the text, converted from HTML. * - * @access public - * @return string + * @return string */ public function get_text() { @@ -328,10 +311,7 @@ public function get_text() } /** - * Prints the text, converted from HTML. - * - * @access public - * @return void + * Prints the text, converted from HTML. */ public function print_text() { @@ -339,11 +319,9 @@ public function print_text() } /** - * Alias to print_text(), operates identically. + * Alias to print_text(), operates identically. * - * @access public - * @return void - * @see print_text() + * @see print_text() */ public function p() { @@ -351,30 +329,24 @@ public function p() } /** - * Sets the allowed HTML tags to pass through to the resulting text. - * - * Tags should be in the form "

", with no corresponding closing tag. + * Sets the allowed HTML tags to pass through to the resulting text. * - * @access public - * @return void + * Tags should be in the form "

", with no corresponding closing tag. */ - public function set_allowed_tags( $allowed_tags = '' ) + public function set_allowed_tags($allowed_tags = '') { - if ( !empty($allowed_tags) ) { + if (!empty($allowed_tags)) { $this->allowed_tags = $allowed_tags; } } /** - * Sets a base URL to handle relative links. - * - * @access public - * @return void + * Sets a base URL to handle relative links. */ - public function set_base_url( $url = '' ) + public function set_base_url($url = '') { - if ( empty($url) ) { - if ( !empty($_SERVER['HTTP_HOST']) ) { + if (empty($url)) { + if (!empty($_SERVER['HTTP_HOST'])) { $this->url = 'http://' . $_SERVER['HTTP_HOST']; } else { $this->url = ''; @@ -382,7 +354,7 @@ public function set_base_url( $url = '' ) } else { // Strip any trailing slashes for consistency (relative // URLs may already start with a slash like "/file.html") - if ( substr($url, -1) == '/' ) { + if (substr($url, -1) == '/') { $url = substr($url, 0, -1); } $this->url = $url; @@ -390,12 +362,9 @@ public function set_base_url( $url = '' ) } /** - * Workhorse function that does actual conversion (calls _converter() method). - * - * @access private - * @return void + * Workhorse function that does actual conversion (calls _converter() method). */ - private function _convert() + protected function _convert() { // Variables used for building the link list $this->_link_list = array(); @@ -419,19 +388,16 @@ private function _convert() } /** - * Workhorse function that does actual conversion. - * - * First performs custom tag replacement specified by $search and - * $replace arrays. Then strips any remaining HTML tags, reduces whitespace - * and newlines to a readable format, and word wraps the text to - * $this->_options['width'] characters. + * Workhorse function that does actual conversion. * - * @param string Reference to HTML content string + * First performs custom tag replacement specified by $search and + * $replace arrays. Then strips any remaining HTML tags, reduces whitespace + * and newlines to a readable format, and word wraps the text to + * $this->_options['width'] characters. * - * @access private - * @return void + * @param string Reference to HTML content string */ - private function _converter(&$text) + protected function _converter(&$text) { // Convert

(before PRE!) $this->_convert_blockquotes($text); @@ -477,19 +443,18 @@ private function _converter(&$text) } /** - * Helper function called by preg_replace() on link replacement. + * Helper function called by preg_replace() on link replacement. * - * Maintains an internal list of links to be displayed at the end of the - * text, with numeric indices to the original point in the text they - * appeared. Also makes an effort at identifying and handling absolute - * and relative links. + * Maintains an internal list of links to be displayed at the end of the + * text, with numeric indices to the original point in the text they + * appeared. Also makes an effort at identifying and handling absolute + * and relative links. * - * @param string $link URL of the link - * @param string $display Part of the text to associate number with - * @access private - * @return string + * @param string $link URL of the link + * @param string $display Part of the text to associate number with + * @return string */ - private function _build_link_list( $link, $display, $link_override = null) + protected function _build_link_list($link, $display, $link_override = null) { $link_method = ($link_override) ? $link_override : $this->_options['do_links']; if ($link_method == 'none') @@ -500,6 +465,7 @@ private function _build_link_list( $link, $display, $link_override = null) if (preg_match('!^(javascript:|mailto:|#)!i', $link)) { return $display; } + if (preg_match('!^([a-z][a-z0-9.+-]+:)!i', $link)) { $url = $link; } else { @@ -526,12 +492,11 @@ private function _build_link_list( $link, $display, $link_override = null) } /** - * Helper function for PRE body conversion. + * Helper function for PRE body conversion. * - * @param string HTML content - * @access private + * @param string HTML content */ - private function _convert_pre(&$text) + protected function _convert_pre(&$text) { // get the content of PRE element while (preg_match('/]*>(.*)<\/pre>/ismU', $text, $matches)) { @@ -544,6 +509,7 @@ private function _convert_pre(&$text) // convert the content $this->pre_content = sprintf('

%s
', preg_replace($this->pre_search, $this->pre_replace, $this->pre_content)); + // replace the content (use callback because content can contain $0 variable) $text = preg_replace_callback('/]*>.*<\/pre>/ismU', array($this, '_preg_pre_callback'), $text, 1); @@ -554,12 +520,11 @@ private function _convert_pre(&$text) } /** - * Helper function for BLOCKQUOTE body conversion. + * Helper function for BLOCKQUOTE body conversion. * - * @param string HTML content - * @access private + * @param string HTML content */ - private function _convert_blockquotes(&$text) + protected function _convert_blockquotes(&$text) { if (preg_match_all('/<\/*blockquote[^>]*>/i', $text, $matches, PREG_OFFSET_CAPTURE)) { $start = 0; @@ -609,12 +574,12 @@ private function _convert_blockquotes(&$text) } /** - * Callback function for preg_replace_callback use. + * Callback function for preg_replace_callback use. * - * @param array PREG matches - * @return string + * @param array PREG matches + * @return string */ - private function _preg_callback($matches) + protected function _preg_callback($matches) { switch (strtolower($matches[1])) { case 'b': @@ -638,12 +603,12 @@ private function _preg_callback($matches) } /** - * Callback function for preg_replace_callback use in PRE content handler. + * Callback function for preg_replace_callback use in PRE content handler. * - * @param array PREG matches - * @return string + * @param array PREG matches + * @return string */ - private function _preg_pre_callback($matches) + protected function _preg_pre_callback($matches) { return $this->pre_content; }