GEWIS / gewisweb

GEWIS Website
https://gewis.nl
GNU General Public License v3.0
16 stars 33 forks source link

Add search highlighting to decision search #1764

Closed tomudding closed 7 months ago

tomudding commented 7 months ago

This allows you to quickly identify your search prompt in the contents of the returned decisions. Through transliteration it is possible to highlight accented text (which is also done by MariaDB) when searching with plain ASCII text, and vice-versa.

The markers are progressively inserted into the original decision contents by iterating with mb_stripos (note: case-insensitive).

image


Original implementation used preg_replace, however, this does not work with the accented characters:

<?= preg_replace(
    sprintf('/(%s)/i', preg_quote($this->escapeHtml($prompt), '/')),
    '<mark>$1</mark>',
    $this->escapeHtml($decision->getContent()),
) ?>

For example, searching for geinstalleerd would return results containing geïnstalleerd. However, these would not be highlighted.

Closes GH-1763.