diff --git a/mod/glossary/view.php b/mod/glossary/view.php index 7d087f5b6ad..66d5dd60a2d 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -353,7 +353,18 @@ /// highlight the term if necessary if ($mode == 'search') { - $entry->highlight = $hook; + //We have to strip any word starting by + and take out words starting by - + //to make highlight works properly + $searchterms = explode(' ', $hook); // Search for words independently + foreach ($searchterms as $key => $searchterm) { + if (preg_match('/^\-/',$searchterm)) { + unset($searchterms[$key]); + } else { + $searchterms[$key] = preg_replace('/^\+/','',$searchterm); + } + } + $strippedsearch = implode(' ', $searchterms); // Rebuild the string + $entry->highlight = $strippedsearch; } /// and finally print the entry.