MDL-23726 fixed phpdocs - credit goes to Henning Bostelmann
[moodle.git] / lib / html2text_readme.txt
blob340fd42646540135cd7c97e98e0159c5e9af86b7
1 html2text.php is a modified copy of a file shipped with the RoundCube project:
3   http://trac.roundcube.net/log/trunk/roundcubemail/program/lib/html2text.php
6 Modifications
7 --------------
9 1- fix for these warnings in cron:
11   "html_entity_decode bug - cannot yet handle MBCS in html_entity_decode()!"
13 by using this code:
15   $tl=textlib_get_instance();
16   $text = $tl->entities_to_utf8($text, true);
18 instead of:
20   $text = html_entity_decode($text, ENT_COMPAT, 'UTF-8');
23 2- fixed error in preg_replace_callback on php4
25 --- a/lib/html2text.php
26 +++ b/lib/html2text.php
27 @@ -468,7 +468,7 @@ class html2text
29          // Run our defined search-and-replace
30          $text = preg_replace($this->search, $this->replace, $text);
31 -        $text = preg_replace_callback($this->callback_search, array('html2text', '_preg_callback'), $text);
32 +        $text = preg_replace_callback($this->callback_search, array(&$this, '_preg_callback'), $text);
34          // Replace known html entities
35          $text = utf8_encode(html_entity_decode($text));
38  -- Francois Marier <francois@catalyst.net.nz>  2009-05-22
41 2- Don't just strip images, replace them with their alt text.
43 index b7e3e3e..96ef508 100644
44 --- a/lib/html2text.php
45 +++ b/lib/html2text.php
46 @@ -237,6 +237,7 @@ class html2text
47          '/<(a) [^>]*href=("|\')([^"\']+)\2[^>]*>(.*?)<\/a>/i',
48                                                     // <a href="">
49          '/<(th)[^>]*>(.*?)<\/th>/i',               // <th> and </th>
50 +        '/<(img)[^>]*alt=\"([^>"]+)\"[^>]*>/i',    // <img> with alt
51      );
53     /**
54 @@ -574,6 +575,8 @@ class html2text
55              return $this->_strtoupper("\n\n". $matches[2] ."\n\n");
56          case 'a':
57              return $this->_build_link_list($matches[3], $matches[4]);
58 +        case 'img':
59 +            return '[' . $matches[2] . ']';
60          }
61      }
63  -- Tim Hunt 2010-08-04