App icon indicating copy to clipboard operation
App copied to clipboard

[$250] Code blocks of only spaces don't render

Open lanitochka17 opened this issue 1 year ago • 32 comments

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 1.4.1-7 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: **Issue reported by:**Applause - Internal Team Slack conversation:

Action Performed:

  1. Go to any chat
  2. Send a text wrapped in two spaced backticks(Eg. Hello ). i.e Have a space between the backticks

Expected Result:

he backtick should be in the code block

Actual Result:

One Backtick is out of the code block

Workaround:

Unknown

Platforms:

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

  • [x] Android: Native
  • [x] Android: mWeb Chrome
  • [x] iOS: Native
  • [x] iOS: mWeb Safari
  • [x] MacOS: Chrome / Safari
  • [x] MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/Expensify/App/assets/78819774/594496a1-8de3-460d-ada7-f2ad8051b361

Bug6285284_1700561421464!image

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01369e16f895581dbb
  • Upwork Job ID: 1726984904265334784
  • Last Price Increase: 2024-04-10

lanitochka17 avatar Nov 21 '23 15:11 lanitochka17

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

melvin-bot[bot] avatar Nov 21 '23 15:11 melvin-bot[bot]

Triggered auto assignment to @twisterdotcom (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

melvin-bot[bot] avatar Nov 21 '23 15:11 melvin-bot[bot]

Bug0 Triage Checklist (Main S/O)

  • [ ] This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • [ ] This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • [ ] This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • [ ] This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • [ ] I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

melvin-bot[bot] avatar Nov 21 '23 15:11 melvin-bot[bot]

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

melvin-bot[bot] avatar Nov 21 '23 15:11 melvin-bot[bot]

Proposal

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

One backtick is outside the code block when we send hello

What is the root cause of that problem?

Here is the regex for the inline code block

        regex: /(\B|_|)&#x60;(.*?\S.*?)&#x60;(\B|_|)(?!&#x60;|[^<]*<\/pre>)/g,

As you can see, we add negative lookahead assertion ?!&#x60; to take the last backtick but didn't take care of the space characters before it.

This is the root cause

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

We need to consider the cases where spaces exist before the backtick Update the above regex to

        regex: /(\B|_|)&#x60;(.*?\S.*?)&#x60;(\B|_|)(?!(\s*&#x60;)|[^<]*<\/pre>)/g,

This works as expected

Result

https://github.com/Expensify/App/assets/126839717/edb45571-b261-4998-9ff3-5429974cf2f4

What alternative solutions did you explore? (Optional)

In cases we want to parse spaces as a valid code like github, we can update the above regex to

         regex: /(\B|_|)&#x60;(.*?[\S ].*?)&#x60;(\B|_|)(?!&#x60;|[^<]*<\/pre>)/g,

https://github.com/Expensify/App/assets/126839717/d5e1e5b5-77b0-4704-8329-a27ac63e9479

s-alves10 avatar Nov 21 '23 16:11 s-alves10

Surely this is a regression from somewhere right? cc @parasharrajat or @allroundexperts might know. I feel like we test markdown endlessly.

twisterdotcom avatar Nov 21 '23 22:11 twisterdotcom

@s-alves10 are you able to find any regression PR recently causing this bug? or it's a new case that we haven't handled before?

hoangzinh avatar Nov 22 '23 01:11 hoangzinh

Inline code regex was changed 3 months ago but that change didn't cause this issue. I don't think this is a recent regression

s-alves10 avatar Nov 22 '23 03:11 s-alves10

@twisterdotcom I don't see any recent PR that caused this. but I agree with you that we test MD endlessly. In the past, I raised the same concern and suggested that we should create a ruleset for all MD syntax. I guess we are still on that step. We should create one to make sure we are not redoing it. Let me know your thoughts.

parasharrajat avatar Nov 22 '23 06:11 parasharrajat

@s-alves10 I tried to apply your proposal but it causes a unit test in expensify-common repo failure. Could you check again? Thanks

Screenshot 2023-11-24 at 08 57 41

hoangzinh avatar Nov 24 '23 01:11 hoangzinh

@hoangzinh

` ` hello ` `
``` ```

Comparing the above two cases, the first case needs to extend the inline code block content as possible including the space character, and the second case needs to extend the content as possible not including the space.

We need to set clear expectation here

Note: I've found that there are some differences in inline code block parsing between GitHub and Expensify. I'd like to know what the Expensify rule is based on

s-alves10 avatar Nov 24 '23 05:11 s-alves10

@twisterdotcom, @hoangzinh Whoops! This issue is 2 days overdue. Let's get this updated quick!

melvin-bot[bot] avatar Nov 27 '23 13:11 melvin-bot[bot]

We need to set clear expectation here

Agreed. @twisterdotcom @lanitochka17, the expectation is not clearly enough. Could we describe it more clearly? Thanks.

Given user type

` ` hello ` `

What is our expectation in compose box?

  1. hello (2 code blocks on 2 sides of hello text, same as Github)
  2. or `hello` (backtick on 2 sides of hello text)

hoangzinh avatar Nov 27 '23 14:11 hoangzinh

I've found that there are some differences in inline code block parsing between GitHub and Expensify. I'd like to know what the Expensify rule is based on

@s-alves10 I don't know too. You can ask in Slack to get the answer.

hoangzinh avatar Nov 27 '23 14:11 hoangzinh

@hoangzinh Let's think about this problem https://github.com/Expensify/App/issues/31633#issuecomment-1821775273 before jumping on proposals.

parasharrajat avatar Nov 27 '23 16:11 parasharrajat

Oh, I thought we already have unit tests for MD to ensure it won't happen again.

In the past, I raised the same concern and suggested that we should create a ruleset for all MD syntax

@rushatgabhane I wasn't involved before. Could you share more about this point? Thanks

hoangzinh avatar Nov 28 '23 15:11 hoangzinh

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

melvin-bot[bot] avatar Nov 28 '23 16:11 melvin-bot[bot]

FWIW, I think it should render like GitHub: hello .

We are also doing a lot of ExpensiMark updates here: https://github.com/Expensify/App/issues/27977#issuecomment-1809820659. Perhaps we should hold Markdown issues on that larger project @parasharrajat / @tomekzaw / @thienlnam?

twisterdotcom avatar Nov 29 '23 04:11 twisterdotcom

I believe this issue is related to https://github.com/Expensify/App/issues/31493 but all the other issues in https://github.com/Expensify/App/issues/27977#issuecomment-1809820659 seem to be independent.

tomekzaw avatar Nov 29 '23 07:11 tomekzaw

We are also doing a lot of ExpensiMark updates here: https://github.com/Expensify/App/issues/27977#issuecomment-1809820659. Perhaps we should hold Markdown issues on that larger project @parasharrajat / @tomekzaw / @thienlnam?

I think we should keep track of all these markdown changes to make sure the expected outcome is correct. Not sure how many of these there are though.

Though since this looks related to https://github.com/Expensify/App/issues/31493, let's just hold this issue on that

thienlnam avatar Nov 29 '23 18:11 thienlnam

Downgrading to Weekly

twisterdotcom avatar Dec 04 '23 13:12 twisterdotcom

Still held on https://github.com/Expensify/App/issues/31493

twisterdotcom avatar Dec 15 '23 00:12 twisterdotcom

Still held.

twisterdotcom avatar Jan 02 '24 15:01 twisterdotcom

Will test this with new markdown when it hits prod.

twisterdotcom avatar Feb 02 '24 17:02 twisterdotcom

Oh, it's still not on web yet: https://expensify.slack.com/archives/C06BDSWLDPB/p1706897366549169.

Making weekly again.

twisterdotcom avatar Feb 05 '24 13:02 twisterdotcom

Still waiting on markdown hitting web.

twisterdotcom avatar Feb 13 '24 21:02 twisterdotcom

Waiting on https://github.com/Expensify/App/issues/36071#issue-2123827690

twisterdotcom avatar Feb 22 '24 22:02 twisterdotcom

Still going to wait on live markdown being everywhere.

twisterdotcom avatar Mar 04 '24 12:03 twisterdotcom

This is still a weird little thing: image

image

twisterdotcom avatar Apr 10 '24 22:04 twisterdotcom

Upwork job price has been updated to $250

melvin-bot[bot] avatar Apr 10 '24 22:04 melvin-bot[bot]