- changed title to Gender game: Highlighting for Portuguese eats up a space
Gender game: Highlighting for Portuguese eats up a space
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)
-
reporter -
Wow. Must have been tired when writing the previous iteration of this comment. Just ignore it.
-
reporter @lokal-profil you could have left the screenshot, though, it would be useful in illustrating the issue :)
-
reporter - changed status to resolved
Change regex matching code. Fixes
#101and lays the foundation to fix non-ASCII characters in word boundaries, as identified in#79.→ <<cset 3676b1d3e06e>>
-
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".
-
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...
-
reporter Actually, I just checked and the live code is now synced again (I had checked last night).
- Log in to comment