-
-
Notifications
You must be signed in to change notification settings - Fork 392
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hashtags parser fixes and improvements #4473
Conversation
Wohooo! Looks real good @leio10, thanks!! Can you add a CHANGELOG entry? I'd add it under I think it'd be awesome if improvements 1 & 2 were applied to the |
@mrcasals great! By the way, I was researching a little and found that Decidim allows unicode chars on usernames (I have a username UPDATE: with this message we can confirm that github doesn't allow unicode in usernames, I've changed it to avoid the mention to the user |
Damn, I guess you're right... 馃槥 |
b1e5c53
to
a7c188c
Compare
@mrcasals Done, I've improved only the users query, without touching the unicode issue for users, as I understand that we don't want to allow unicode on usernames. Also, I've added the changelog entry. Also, I've remembered another improvement I made to both parsers: I changed the boundaries for the regular expression. Instead of searching for the line starting or an space, I search for any word boundary. This allow to detect hashtags and users in contents like |
馃帺 What? Why?
When creating a proposal, the hashtag
#acci贸n_mutante
is parsed as#acci
and the rest of the characters are left as plain text. When looking for fixing this, I've found other aspects of the code that I tried to improve:HASHTAG_REGEX
was not taking unicode characters into account. Also, it was defined in the model, while it is mainly related to the parser.find_or_create_by
executed for each hashtag detected. I've replaced with a query for every hashtag found in the content, and a creation for each non-existing hashtag.I think that, at least, improvements 1 and 2 could be applied to the
UserParser
class, I can add them in this PR if you agree with these improvements.馃搶 Related Issues
馃搵 Subtasks
CHANGELOG
entry馃摲 Screenshots (optional)