Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add search highlighting to decision search #1764

Merged

Conversation

tomudding
Copy link
Member

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.

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).

---

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

```php
<?= 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.
@tomudding tomudding merged commit 4c2447f into GEWIS:main Nov 19, 2023
4 checks passed
github-actions bot added a commit that referenced this pull request Nov 19, 2023
Tom Udding: Merge pull request #1764 from tomudding/feature/marked-decision-search-results

Add search highlighting to decision search

Co-authored-by: tomudding <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Highlight search prompt in decision search
1 participant