MDL-51524 libraries: Update to latest version of html2text

We were previously using an ancient version of html2text from RoundCube
with many customisations.

This patchset moves to the version included in the latest version of
HTML2Text, and wraps the library in a moodle-provided class. This
moves all previous hacks away from that class.

Unfortunately, two hacks still remain - two of the functions in the
RoundCube class are private, and must be modified to protected in order to
use the class effectively.
This commit is contained in:
Andrew Nicols
2015-10-12 09:35:58 +08:00
parent 74fad2ce3d
commit ec2d33dfcd
9 changed files with 687 additions and 780 deletions
+11 -4
View File
@@ -1850,13 +1850,20 @@ function markdown_to_html($text) {
* @return string plain text equivalent of the HTML.
*/
function html_to_text($html, $width = 75, $dolinks = true) {
global $CFG;
require_once($CFG->libdir .'/html2text.php');
require_once($CFG->libdir .'/html2text/lib.php');
$h2t = new html2text($html, false, $dolinks, $width);
$result = $h2t->get_text();
$options = array(
'width' => $width,
'do_links' => 'table',
);
if (empty($dolinks)) {
$options['do_links'] = 'none';
}
$h2t = new core_html2text($html, $options);
$result = $h2t->getText();
return $result;
}