Merge branch 'MDL-34171_22' of git://github.com/timhunt/moodle into MOODLE_22_STABLE
[moodle.git] / lib / html2text_readme.txt
blob7058045e5fcd862f3589f433713a962de74bd1cd
1 html2text.php is an unmodified copy of a file shipped with the RoundCube project:
3   http://trac.roundcube.net/log/trunk/roundcubemail/program/lib/html2text.php
5  -- Francois Marier <francois@catalyst.net.nz>  2009-05-22
8 Modifications
9 --------------
11 1- Don't just strip images, replace them with their alt text.
13 index b7e3e3e..96ef508 100644
14 --- a/lib/html2text.php
15 +++ b/lib/html2text.php
16 @@ -237,6 +237,7 @@ class html2text
17          '/<(a) [^>]*href=("|\')([^"\']+)\2[^>]*>(.*?)<\/a>/i',
18                                                     // <a href="">
19          '/<(th)[^>]*>(.*?)<\/th>/i',               // <th> and </th>
20 +        '/<(img)[^>]*alt=\"([^>"]+)\"[^>]*>/i',    // <img> with alt
21      );
23     /**
24 @@ -574,6 +575,8 @@ class html2text
25              return $this->_strtoupper("\n\n". $matches[2] ."\n\n");
26          case 'a':
27              return $this->_build_link_list($matches[3], $matches[4]);
28 +        case 'img':
29 +            return '[' . $matches[2] . ']';
30          }
31      }
33 -- Tim Hunt 2010-08-04
35 2- No strip slashes, we do not use magic quotes any more in Moodle 2.0 or later
37 3- Use textlib, not crappy functions that break UTF-8, in the _strtoupper method.
39 Index: lib/html2text.php
40 --- lib/html2text.php   2 Sep 2010 12:49:29 -0000   1.16
41 +++ lib/html2text.php   2 Nov 2010 19:57:09 -0000
42 @@ -580,9 +580,7 @@
43       */
44      function _strtoupper($str)
45      {
46 -        if (function_exists('mb_strtoupper'))
47 -            return mb_strtoupper($str);
48 -        else
49 -            return strtoupper($str);
50 +        $tl = textlib_get_instance();
51 +        return $tl->strtoupper($str);
52      }
53  }
55 -- Tim Hunt 2010-11-02
57 4 - Make sure html2text does not destroy '0'.
59 index e2d0dff..9cc213d 100644
60 --- a/lib/html2text.php
61 +++ b/lib/html2text.php
62 @@ -335,7 +335,7 @@ class html2text
63       */
64      function html2text( $source = '', $from_file = false, $do_links = true, $wi     {
65 -        if ( !empty($source) ) {
66 +        if ($source !== '') {
67              $this->set_html($source, $from_file);
68          }
70 -- Tim Hunt 2011-09-21