1 --- roundcube-0.2~alpha/program/lib/html2text.php 2008-04-12 15:54:45.000000000 +0200
2 +++ roundcube-0.2~alpha/program/lib/html2text.php 2008-12-13 14:21:44.000000000 +0100
8 + * List of preg* regular expression patterns to search for
9 + * and replace using callback function.
11 + * @var array $callback_search
14 + var $callback_search = array(
15 + '/<(h)[123456][^>]*>(.*?)<\/h[123456]>/i', // H1 - H3
16 + '/<(b)[^>]*>(.*?)<\/b>/i', // <b>
17 + '/<(strong)[^>]*>(.*?)<\/strong>/i', // <strong>
18 + '/<(a) [^>]*href=("|\')([^"\']+)\2[^>]*>(.*?)<\/a>/i',
20 + '/<(th)[^>]*>(.*?)<\/th>/i', // <th> and </th>
24 * List of preg* regular expression patterns to search for,
25 * used in conjunction with $replace.
27 "/[\n\t]+/", // Newlines and tabs
28 '/<script[^>]*>.*?<\/script>/i', // <script>s -- which strip_tags supposedly has problems with
29 //'/<!-- .* -->/', // Comments -- which strip_tags might have problem a with
30 - '/<a [^>]*href=("|\')([^"\']+)\1[^>]*>(.+?)<\/a>/ie', // <a href="">
31 - '/<h[123][^>]*>(.+?)<\/h[123]>/ie', // H1 - H3
32 - '/<h[456][^>]*>(.+?)<\/h[456]>/ie', // H4 - H6
34 '/<br[^>]*>/i', // <br>
35 - '/<b[^>]*>(.+?)<\/b>/ie', // <b>
36 '/<i[^>]*>(.+?)<\/i>/i', // <i>
37 '/(<ul[^>]*>|<\/ul>)/i', // <ul> and </ul>
38 '/(<ol[^>]*>|<\/ol>)/i', // <ol> and </ol>
40 '/(<table[^>]*>|<\/table>)/i', // <table> and </table>
41 '/(<tr[^>]*>|<\/tr>)/i', // <tr> and </tr>
42 '/<td[^>]*>(.+?)<\/td>/i', // <td> and </td>
43 - '/<th[^>]*>(.+?)<\/th>/ie', // <th> and </th>
48 ' ', // Newlines and tabs
49 '', // <script>s -- which strip_tags supposedly has problems with
50 //'', // Comments -- which strip_tags might have problem a with
51 - '$this->_build_link_list("\\2", "\\3")', // <a href="">
52 - "strtoupper(\"\n\n\\1\n\n\")", // H1 - H3
53 - "ucwords(\"\n\n\\1\n\")", // H4 - H6
56 - 'strtoupper("\\1")', // <b>
58 "\n\n", // <ul> and </ul>
59 "\n\n", // <ol> and </ol>
61 "\n\n", // <table> and </table>
62 "\n", // <tr> and </tr>
63 "\t\t\\1\n", // <td> and </td>
64 - "strtoupper(\"\t\t\\1\n\")", // <th> and </th>
70 // Run our defined search-and-replace
71 $text = preg_replace($this->search, $this->replace, $text);
72 + $text = preg_replace_callback($this->callback_search, array('html2text', '_preg_callback'), $text);
74 // Strip any other HTML tags
75 $text = strip_tags($text, $this->allowed_tags);
78 return $display . ' [' . ($index+1) . ']';
82 + * Callback function for preg_replace_callback use.
84 + * @param array PREG matches
88 + function _preg_callback($matches)
94 + return $this->_strtoupper($matches[2]);
96 + return $this->_strtoupper("\t\t". $matches[2] ."\n");
98 + return $this->_strtoupper("\n\n". $matches[2] ."\n\n");
100 + return $this->_build_link_list($matches[3], $matches[4]);
105 + * Strtoupper multibyte wrapper function
111 + function _strtoupper($str)
113 + if (function_exists('mb_strtoupper'))
114 + return mb_strtoupper($str);
116 + return strtoupper($str);
121 \ Pas de fin de ligne à la fin du fichier.