-
Notifications
You must be signed in to change notification settings - Fork 135
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
fix: no trimming for link name #773
Conversation
@DylanDylann for review |
@DylanDylann this is ready for review. |
@dominictb Did you test this change? |
Tested in the |
@@ -298,7 +298,7 @@ export default class ExpensiMark { | |||
{ | |||
name: 'reportMentions', | |||
|
|||
regex: /(?<![^ \n*~_])(#[\p{Ll}0-9-]{1,80})(?![^<]*(?:<\/pre>|<\/code>))/gimu, | |||
regex: /(?<![^ \n*~_])(#[\p{Ll}0-9-]{1,80})(?![^<]*(?:<\/pre>|<\/code>|<\/a>))/gimu, |
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.
@dominictb Could you explain why we need to change this regex?
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.
test('room mention with space inside link should not be rendered', () => { |
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.
@dominictb In this case, shouldKeepRawInput is false, right?
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.
So I don't think this test relate to our change
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.
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.
I'm under the assumption that before this change, the #room
text shouldn't have the report-mention markdown if it is inside a link markdown syntax (see the image above)
However, after my change, the #room
text will now have the report-mention markdown style (check the image below), but I believe this only happens in the markdown input, not when we save/send the message as we have already trim the extra space at that point, hence the #room
text won't have the report-mention markdown style. So, the question is: is this acceptable to show the report-mention markdown style in the markdown input in this case or not? It might be confusing for the user because what they saw when typing and when viewing the sent message is 2 different thing.
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.
@dominictb Yeah, agree that the report-mention markdown style shouldn't be rendered. But my curious why we have different behaviors when trimming spaces. Could you refer to a code link for this point?
but I believe this only happens in the markdown input
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.
But my curious why we have different behaviors when trimming spaces
that is because we're trying to match and apply report-mention rule to the link name, and since the original regex of the report-mention doesn't account for the case where link name can have spaces on both end -> hence the mentioned problem
The solution is to update the regex, making sure that if the mention-report
is between <a/>
tag, we won't render the markdown style. We have the same logic to prevent applying mention-report
markdown style in pre
and code
block, so it should be straightforward
but I believe this only happens in the markdown input
We only keep the space in when shouldKeepRawInput = true
, and this particular problem only happens when the link name have redundant spaces on either end. So, it only happens in the markdown input (shouldKeepRawInput = true
), but not when we display the sent message in the app (``shouldKeepRawInput = false`)
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, I understand your problem and solution. But the RCA isn't clear to me
But my curious why we have different behaviors when trimming spaces. Could you refer to a code link for this point?
For this question, I am curious why the old mention-report regex works well when we trim spaces but It fails when we keep trailing spaces
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.
Ahhh, see. It dues to the negative lookbehind. Sorry for my confusion
Please include a video as evidence. |
Reviewer Checklist
Screenshots/VideosThis change only be applied to react-native-live-markdown (We only use parser.replace function with shouldKeepRawInput: true on react-native-live-markdown repo), then I will make a full test on this PR |
Pending this comment |
Waiting on 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.
@Gonals Let's move forward
🚀Published to npm in v2.0.72 |
Fixed Issues
$ Expensify/App#45623
Tests
Already in the PR
Will covered in
react-native-live-markdown
PRQA
Will covered in the app PR
Live markdown.
Linked PRs
Expensify/react-native-live-markdown#449 (Evidence is here)