diff --git a/mod/forum/search.php b/mod/forum/search.php index 727743e3a2d..fe947b26885 100644 --- a/mod/forum/search.php +++ b/mod/forum/search.php @@ -204,7 +204,18 @@ //Use highlight() with nonsense tags to spot search terms in the //actual text content first. fiedorow - 9/2/2005 $missing_terms = ""; - $message = highlight($strippedsearch,format_text($post->message, $post->format, NULL, $course->id), + + // Hack for posts of format FORMAT_PLAIN. Otherwise html tags added by + // the highlight() call bellow get stripped out by forum_print_post(). + if ($post->format == FORMAT_PLAIN) { + $post->message = s($post->message); + $post->message = rebuildnolinktag($post->message); + $post->message = str_replace(' ', '  ', $post->message); + $post->message = nl2br($post->message); + $post->format = FORMAT_HTML; + } + + $message = highlight($strippedsearch, format_text($post->message, $post->format, NULL, $course->id), 0,'',''); foreach ($searchterms as $searchterm) {