]> git.mjollnir.org Git - moodle.git/commitdiff
Use the new html2text function for converting html to text.
authormoodler <moodler>
Fri, 7 Nov 2003 03:27:21 +0000 (03:27 +0000)
committermoodler <moodler>
Fri, 7 Nov 2003 03:27:21 +0000 (03:27 +0000)
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.

lib/weblib.php

index 6bb5ea2f41da29427134efe500b87b59d4802d96..ffe3cf4e7d6c8c4602f6b7def4b5e31d0e02d7eb 100644 (file)
@@ -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('(<a [^<]*href=["|\']?([^ "\']*)["|\']?[^>]*>([^<]*)</a>)','\\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.