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

Prevent italic or strikethrough emojis on Android #534

Closed
wants to merge 20 commits into from

Conversation

Skalakid
Copy link
Collaborator

@Skalakid Skalakid commented Nov 5, 2024

Details

This PR fixes adding italics and strikethrough style to the emojis on Android and web platforms

Related Issues

Expensify/App#14676

Manual Tests

  1. To the text that contains emojis, add italics styling, e.g. _🥰 test 😇 test 🥹_
  2. Verify if the text has italics style and emojis don't
  3. Verify if it still works when adding other styles around it, e.g. # *~_🥰 test 😇 test 🥹_~*
  4. Verify if emojis aren't strikethrough
  5. Test it with different style combinations

Linked PRs

@Skalakid Skalakid marked this pull request as draft November 5, 2024 16:01
@Skalakid Skalakid marked this pull request as ready for review November 7, 2024 13:40
Copy link
Collaborator

@tomekzaw tomekzaw left a comment

Choose a reason for hiding this comment

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

Left some suggestions in the comments, also a unit test suite would be much appreciated.

@tomekzaw tomekzaw changed the title Fix emoji formatting Prevent italic or strikethrough emojis on Android Nov 11, 2024
@Skalakid Skalakid requested a review from tomekzaw November 12, 2024 14:43
Copy link
Collaborator

@tomekzaw tomekzaw left a comment

Choose a reason for hiding this comment

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

Also, please provide some unit tests in Java to verify the implementation.

@289Adam289
Copy link

I've tested this pr on very example app platform and E/App platforms and I could not find anything. Everything works well including preventing formatting on emojis.

Comment on lines 3 to 5
import org.json.JSONException;
import org.json.JSONObject;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
import org.json.JSONException;
import org.json.JSONObject;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just FYI, I also needed class MarkdownRange so I added it in #559. I hope you can reuse mine in this PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done in 692de7c

@Skalakid Skalakid requested a review from tomekzaw December 5, 2024 11:29
@Skalakid Skalakid requested review from tomekzaw and BartoszGrajdek and removed request for tomekzaw and BartoszGrajdek December 18, 2024 11:36
import java.util.ArrayList;
import java.util.List;

public class RangeSplitter {
public static ArrayList<MarkdownRange> splitRangesOnEmojis(@NonNull List<MarkdownRange> markdownRanges, @NonNull String type) {
Systrace.beginSection(0, "splitRangesOnEmojis");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please wrap beginSection/endSection calls with try/finally block

Comment on lines 47 to 49
if (newRange.getLength() > 0) {
newRanges.add(newRange);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this check be symmetric? So it covers both _text😀_ and _😀text_?

Also, let's rename newRange and currentRange to leftRange and rightRange.

Let's avoid creating newRange object at all if possible, i.e. move the constructor call into the conditional.

@Skalakid
Copy link
Collaborator Author

We decided to close this PR and rewrite the solution to TypeScript at #591. After the discussion, we agreed that after enabling custom parsers in the live markdown library, it would be better not to interfere with their results. Because of that, we moved the range splitting algorithm to the parseExpensiMark so all platforms get the split ranges. It also gives a choice in custom parser implementation if someone wants to remove styles from emojis

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.

3 participants