weblib MDL-22664 html_to_text should not strip images, it should replace them by their alt text.

Also, an new optional argument to html_to_text to control word-wrapping.
This commit is contained in:
Tim Hunt
2010-08-04 17:39:56 +00:00
parent 791325ae6c
commit f47906fbf5
4 changed files with 47 additions and 5 deletions
+5 -4
View File
@@ -2288,17 +2288,18 @@ function markdown_to_html($text) {
/**
* Given HTML text, make it into plain text using external function
*
* @uses $CFG
* @param string $html The text to be converted.
* @return string
* @param integer $width Width to wrap the text at. (optional, default 75 which
* is a good value for email. 0 means do not limit line length.)
* @return string plain text equivalent of the HTML.
*/
function html_to_text($html) {
function html_to_text($html, $width = 75) {
global $CFG;
require_once($CFG->libdir .'/html2text.php');
$h2t = new html2text($html);
$h2t = new html2text($html, false, true, $width);
$result = $h2t->get_text();
return $result;