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

Add handling short mentions tags to ExpensiMark #824

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Kicu
Copy link

@Kicu Kicu commented Dec 21, 2024

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
    • prev: <a href=\"mailto:test@gmail.com\">test@gmail.com</a>@gmail.com
    • now: <a href=\"mailto:test@gmail.com\">test@gmail.com</a><mention-short>@gmail.com</mention-short> - @gmail.com is a correct mention

In 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

  1. What does QA need to do to validate your changes?
  2. What areas to they need to test for regressions?

Copy link

github-actions bot commented Dec 21, 2024

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Kicu
Copy link
Author

Kicu commented Dec 21, 2024

I have read the CLA Document and I hereby sign the CLA

@Kicu Kicu force-pushed the kicu/38025-short-mentions branch from 275cc20 to c9e41a1 Compare December 30, 2024 09:44
CLABotify added a commit to Expensify/CLA that referenced this pull request Dec 30, 2024
@Kicu Kicu force-pushed the kicu/38025-short-mentions branch from c9e41a1 to bb4cc97 Compare January 7, 2025 14:17
@Kicu Kicu force-pushed the kicu/38025-short-mentions branch from e7b887c to 206d18c Compare January 8, 2025 12:59
@Kicu Kicu changed the title [WIP] Add handling possible short mentions tags to ExpensiMark Add handling possible short mentions tags to ExpensiMark Jan 8, 2025
@Kicu Kicu changed the title Add handling possible short mentions tags to ExpensiMark Add handling short mentions tags to ExpensiMark Jan 8, 2025
@Kicu Kicu force-pushed the kicu/38025-short-mentions branch from 206d18c to f7e27c7 Compare January 8, 2025 13:13
@Kicu Kicu marked this pull request as ready for review January 8, 2025 13:14
@Kicu Kicu requested a review from a team as a code owner January 8, 2025 13:14
@melvin-bot melvin-bot bot requested review from arosiclair and removed request for a team January 8, 2025 13:14
@arosiclair arosiclair requested review from puneetlath and thienlnam and removed request for arosiclair January 8, 2025 16:10
@shubham1206agra
Copy link

Commenting here for assignment.

Comment on lines 1671 to 1681
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);
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

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?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.

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

Successfully merging this pull request may close these issues.

2 participants