From: moodler Date: Fri, 7 Nov 2003 03:27:21 +0000 (+0000) Subject: Use the new html2text function for converting html to text. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=6ff45b597e5c1378a5101bdb32c19528c2f73d87;p=moodle.git Use the new html2text function for converting html to text. This function is still being tested - it seems fast enough so far but I'm checking it in to do some further testing on moodle.org for a while. --- diff --git a/lib/weblib.php b/lib/weblib.php index 6bb5ea2f41..ffe3cf4e7d 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -536,6 +536,10 @@ function format_text_email($text, $format) { return strtr(strip_tags($text), array_flip(get_html_translation_table(HTML_ENTITIES))); break; + case FORMAT_HTML: + return html_to_text($text); + break; + default: // FORMAT_MOODLE or anything else $text = eregi_replace('(]*>([^<]*))','\\3 [\\2]', $text); return strtr(strip_tags($text), array_flip(get_html_translation_table(HTML_ENTITIES))); @@ -682,6 +686,15 @@ function wiki_to_html($text) { return $wiki->format($text); } +function html_to_text($html) { +/// Given HTML text, make it into plain text using external function + + require_once("$CFG->libdir/html2text.php"); + + return html2text($html); +} + + function convert_urls_into_links(&$text) { /// Given some text, it converts any URLs it finds into HTML links.