-
Notifications
You must be signed in to change notification settings - Fork 136
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 handling short mentions tags to ExpensiMark #824
base: main
Are you sure you want to change the base?
Add handling short mentions tags to ExpensiMark #824
Conversation
All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
275cc20
to
c9e41a1
Compare
c9e41a1
to
bb4cc97
Compare
e7b887c
to
206d18c
Compare
206d18c
to
f7e27c7
Compare
Commenting here for assignment. |
test('Test for email with test+1@gmail.com@gmail.com', () => { | ||
const testString = 'test+1@gmail.com@gmail.com'; | ||
const resultString = '<a href="mailto:test+1@gmail.com">test+1@gmail.com</a>@gmail.com'; | ||
const resultString = '<a href="mailto:test+1@gmail.com">test+1@gmail.com</a><mention-short>@gmail.com</mention-short>'; | ||
expect(parser.replace(testString)).toBe(resultString); | ||
}); | ||
|
||
test('Test for email with test@gmail.com@gmail.com', () => { | ||
const testString = 'test@gmail.com@gmail.com'; | ||
const resultString = '<a href="mailto:test@gmail.com">test@gmail.com</a>@gmail.com'; | ||
const resultString = '<a href="mailto:test@gmail.com">test@gmail.com</a><mention-short>@gmail.com</mention-short>'; | ||
expect(parser.replace(testString)).toBe(resultString); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be invalid emails after all. See https://stackoverflow.com/questions/12355858/how-many-symbol-can-be-in-an-email-address
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah indeed test+1@gmail.com@gmail.com
looks like invalid email.
But I thought the reasoning was that the parser should treat it as a separate email (1st part) and then just text @gmail.com
which now becomes a short mention.
Do you want me to change anything related to this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No.
Details
This is part of allowing to style and highlight short-mentions inside live-markdown when user is writing/editing their message. More details here: Expensify/App#38025 (comment)
The purpose of this PR is to add handling of (possible) short mention tags to ExpensiMark.
In this PR we define "short-mention" as anything after
@
character that would be a valid email prefix.Examples:
Why "possible" short mentions
The only way for us to actually render short-mentions inside
react-native-live-markdown
(and other code using ExpensiMark) is to somehow have the list of all possible user logins, and then checking whether the user typed mention matches any of them.However such list should not and cannot be shared in any way to ExpensiMark, as this is just a simple parser. But we still need to some kind of output from ExpensiMark, to understand that there are mentions inside parsed text, so that we can later try and match them to user onyx data.
This creates some changes in how ExpensiMark interprets text, because something that in the past would be considered just normal text, might now be a short mention.
Example of parser output that changed (based on tests)
test@gmail.com@gmail.com
<a href=\"mailto:test@gmail.com\">test@gmail.com</a>@gmail.com
<a href=\"mailto:test@gmail.com\">test@gmail.com</a><mention-short>@gmail.com</mention-short>
- @gmail.com is a correct mentionIn total I had to edit ~5 tests, all the other ones are passing correctly.
CC @puneetlath @tomekzaw @BartoszGrajdek
Fixed Issues
$ Expensify/App#38025
Tests
I made sure all existing unit tests pass, and added specific tests for short mentions
QA