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

The regex that detects mentions is assuming English (and similar) languages #121

Open
yossizahn opened this issue Jan 11, 2020 · 4 comments

Comments

@yossizahn
Copy link

yossizahn commented Jan 11, 2020

The regex that detects "mentions" is assuming that an @ character is only the start of a mention if it follows a whitespace character (or a very limited number of other characters).
This assumption isn't true in other languages where a preposition may be expressed by prefixing the subject word.
e.g. In English we say "... that @xyz said..."
In Hebrew this is written as: "ש-@xyz אמר", or even as "ש@xyz אמר" without the hyphen.
I would suggest adding an allowance for hyphens at minimum.

edit: I see that Github detects all the mentions here... (sorry @xyz for awakening you from your slumber...)

@julianlam
Copy link
Owner

Understood, but unfortunately I had to make concessions as to how the mentions regex matcher works...

For example, I don't want it to trigger the mentions autocomplete dialog when you simply type an email address (e.g. [email protected])

Unfortunately, I can't think of a solution around this. Do other services provide mentions in this manner?

I am attempting to try with GitHub right now, but it also seems to want a whitespace character before the mention.

@yossizahn
Copy link
Author

For example, I don't want it to trigger the mentions autocomplete dialog when you simply type an email address

Perhaps detect and linkify mentions anywhere they occur but only trigger the autocomplete when after a whitespace.

I am attempting to try with GitHub right now, but it also seems to want a whitespace character before the mention.

Github seems to be quite clever about this and only linkifies mentions which are not proceeded by [0-9a-zA-Z]
It is also has stricter rules for triggering autocomplete than for linkifying.

@julianlam
Copy link
Owner

Right... and just like GitHub (not that I'm comparing or anything), we also have separate logic for linkifying mentions vs. spawning the autocomplete dialog.

They each have their own regex, although they are for all intents and purposes identical when it comes to matching a mention.

It's because of unicode characters that we couldn't simply check for the word boundary meta character \b... we could use the XRegExp library for server-side (so... the linkifying part), but it wouldn't resolve the autocomplete issue. If that's an okay concession for you, then I can look into maybe implementing XRegExp (though no guarantees)

@yossizahn
Copy link
Author

If that's an okay concession for you,

Anything is better than nothing :)
The main issue is actually not the auto-complete or the linkifying but the fact that the user doesn't get notified about the mention.
Fixing it server side is enough for that.

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

No branches or pull requests

2 participants