Gender game: Highlighting for Portuguese eats up a space

Issue #101 resolved
Waldir Pimenta created an issue

With the recent change in the highlighting method in 5bfab47, the replacement string is identical for all languages, but in the case of Portuguese, it needed a space before the span. (As the list of supported languages expands, I'd expect other languages to also have similar requirements.)

This means that currently the use of a space rather than a word boundary character (\b) at the beginning of the Portuguese regex (which is necessary because javascript doesn't recognize accented characters as word characters) results in that leading space being chopped up in the highlighted result.

The solution could be either including the space in the regex group, or having custom replacement strings for each language (or at least an overridable default).

The first approach is simpler but results in the highlight improperly including a space before the relevant word; the second is more complex but would allow for this issue (as well as future ones with other languages) to be solved cleanly.

Comments (7)

  1. Lokal Profil

    Wow. Must have been tired when writing the previous iteration of this comment. Just ignore it.

  2. Waldir Pimenta reporter

    @lokal-profil you could have left the screenshot, though, it would be useful in illustrating the issue :)

  3. Lokal Profil

    The current one matches correctly but replaces incorrectly (see below). Sorry for nuking the last screenshot.

    Edit: To clarify the screenshot. The problem is that "foi" and "foi um" get replaced by "foifoi" and "foi foi".

    Screenshot from 2014-06-11 09:11:17.png

  4. Waldir Pimenta reporter

    Yeah, I noticed it too. It's already been fixed in e7d7b17 but the code hasn't updated in the live game yet. Not sure how to trigger a cache invalidation or whatever is needed to update the live version...

  5. Waldir Pimenta reporter

    Actually, I just checked and the live code is now synced again (I had checked last night).

  6. Log in to comment