diff --git a/course/renderer.php b/course/renderer.php index 437c406e9bb9c..b793cfcf5d7bc 100644 --- a/course/renderer.php +++ b/course/renderer.php @@ -2022,7 +2022,10 @@ public function get_course_formatted_summary($course, $options = array()) { $summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', null); $summary = format_text($summary, $course->summaryformat, $options); if (!empty($this->searchcriteria['search'])) { - $summary = highlight($this->searchcriteria['search'], $summary); + // The course summary we are highlighting is a formatted string, + // so the search term should also be a formatted string to match. + $search = format_string($this->searchcriteria['search'], true, $options); + $summary = highlight($search, $summary); } return $summary; } @@ -2041,7 +2044,10 @@ public function get_course_formatted_name($course, $options = array()) { } $name = format_string(get_course_display_name_for_list($course), true, $options); if (!empty($this->searchcriteria['search'])) { - $name = highlight($this->searchcriteria['search'], $name); + // The course name we are highlighting is a formatted string, + // so the search term should also be a formatted string to match. + $search = format_string($this->searchcriteria['search'], true, $options); + $name = highlight($search, $name); } return $name; }