Skip to content
Browse files
Fix broken search results highlighting
  • Loading branch information
flodolo authored and pascalchevrel committed Apr 4, 2016
1 parent 3bc1a0a commit b80dfaf2d91117b098f43daeffd6ea79101f740c
Showing 2 changed files with 15 additions and 1 deletion.
@@ -119,8 +119,21 @@ public static function markString($needle, $haystack)
public static function highlightString($str)
[^←→]: matches any character but the marker characters.
[^←→]|(?R): matches any character but the marker characters,
or recursively the entire pattern.
This is wrapped in a non capturing group (?:), since we're
only interested in the content of the more external markers.
For example, for “←←A→dd→” we're only interested in “←A→dd”,
capturing “←A→” is not useful.
Internal extra markers are later removed by str_replace.
See also
$str = preg_replace(
"<span class='highlight'>$1</span>",
@@ -176,6 +176,7 @@ public function highlightStringDP()
['←Cronologia→ di navigazione', '<span class=\'highlight\'>Cronologia</span> di navigazione'],
['←servi←ce→→', '<span class=\'highlight\'>service</span>'],
['Cronologia di navigazione', 'Cronologia di navigazione'],
['←←A→dd→ more ←se←a→rch→ ←engine→s…', '<span class=\'highlight\'>Add</span> more <span class=\'highlight\'>search</span> <span class=\'highlight\'>engine</span>s…'],

0 comments on commit b80dfaf

Please sign in to comment.