Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.58k stars 2.92k forks source link

[$250] Chat - A message between only 1 backtick creates a code block #53144

Open lanitochka17 opened 4 days ago

lanitochka17 commented 4 days ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.0.66-8 Reproducible in staging?: Y Reproducible in production?: Y If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/5175216 Email or phone of affected tester (no customers): buiminhanh08062023+1996@gmail.com Issue reported by: Applause - Internal Team

Action Performed:

  1. Open testing app
  2. Open any conversation
  3. Click on compose box
  4. Send a message between three backticks "text"

Expected Result:

Because a message between three backticks should create a code block, so that it should create a code block with "text" in this code block

Actual Result:

It created a code block with "text" in this code block. It means only need a pair of backtick to create a code block

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/user-attachments/assets/78feb86d-8c88-455a-b7ac-792e4a5a1dea

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021862475730653768184
  • Upwork Job ID: 1862475730653768184
  • Last Price Increase: 2024-11-29
Issue OwnerCurrent Issue Owner: @DylanDylann
melvin-bot[bot] commented 4 days ago

Triggered auto assignment to @sonialiap (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

M00rish commented 4 days ago

Edited by proposal-police: This proposal was edited at 2024-11-28 14:20:12 UTC.

Proposal:

Please re-state the problem that we are trying to solve in this issue.

Chat - A message between only 1 backtick creates a code block

What is the root cause of that problem?

https://github.com/Expensify/expensify-common/blob/302e37e40d9d7e718e7c1c3d98faaa644b51da9d/lib/ExpensiMark.ts#L170C5-L174C154

the codefence regex will not match because it's requiring a newline character (\r\n|\n), and that requirement for newline characters prevents it from matching inline code, so this will work on multiple line only but not inline.

Then after, the inlinecode regex match which only requires one backtick and it's rule get applied and we see two other backticks treated as normal text.

What changes do you think we should make in order to solve the problem?

we need to update the codefence regex to deal with both cases and allow content within the block to span multiple lines or remain inline.

regex: /(```)(.*?)(?:(\r\n|\n).*?(\r\n|\n)|.*?)(```)/g

We may want to remove inlinecode rule, it's confusing to have both at the same time I think.

What alternative solutions did you explore? (Optional)

N/A

melvin-bot[bot] commented 1 day ago

Job added to Upwork: https://www.upwork.com/jobs/~021862475730653768184

melvin-bot[bot] commented 1 day ago

Triggered auto assignment to Contributor-plus team member for initial proposal review - @DylanDylann (External)

Anaslancer commented 1 day ago

Proposal

Please re-state the problem that we are trying to solve in this issue.

Chat - A message between only 1 backtick creates a code block

What is the root cause of that problem?

When user input ```test```, it didn't match with the current regex. regex: /(```.*?(\r\n|\n))((?:\s*?(?!(?:\r\n|\n)?```(?!`))[\S])+\s*?(?:\r\n|\n))(```)/g,

What changes do you think we should make in order to solve the problem?

We can change this regex like below. regex: /(`{3}.*?(\r\n|\n))((?:\s*?(?!(?:\r\n|\n)?`{3}(?!`))[\S])+\s*?(?:\r\n|\n))(`{3})|`{3}(.*?)`{3}/g I tested this regex; Screenshot_17 Screenshot_18

What alternative solutions did you explore? (Optional)

N/A

Contributor details

Your Expensify account email: anasup1995@gmail.com Upwork Profile Link: https://www.upwork.com/freelancers/~01aff093c9a804b145

melvin-bot[bot] commented 1 day ago

✅ Contributor details stored successfully. Thank you for contributing to Expensify!