Skip to content

[HOLD for payment 2023-07-21] [$1000] Web - Heading after quote is not rendering #21846

Closed

Description

@kbecciv

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


Action Performed:

  1. Go a chat and add a comment
> quote
# heading
  1. Notice that heading is displayed in plain text

Expected Result:

Heading should be rendered

Actual Result:

Markdown heading syntax is not rendering

Workaround:

Unknown

Platforms:

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

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.32-5
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
Notes/Photos/Videos: Any additional supporting documentation

https://github.com/Expensify/App/assets/93399543/8626f832-2e3e-4705-9f42-59b82d7d7172
https://github.com/Expensify/App/assets/93399543/7f95a2a1-6c96-4a48-afbe-712edae38043

Expensify/Expensify Issue URL:
Issue reported by: @eh2077
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1687921581684809

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01e498007bd2f0de5b
  • Upwork Job ID: 1674345101139329024
  • Last Price Increase: 2023-07-06

Activity

  1. added
    NewFeatureSomething to build that is a new item.
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jun 28, 2023
  2. melvin-bot commented on Jun 28, 2023

    @melvin-bot
  3. melvin-bot commented on Jun 28, 2023

    @melvin-bot

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

  4. melvin-bot commented on Jun 28, 2023

    @melvin-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
  5. melvin-bot commented on Jun 28, 2023

    @melvin-bot

    Triggered auto assignment to Design team member for new feature review - @shawnborton (NewFeature)

  6. spcheema commented on Jun 28, 2023

    @spcheema
    Contributor

    Proposed solution

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

    Heading after quote is not rendering

    What is the root cause of that problem?
    The root cause of the problem is that \n is deliberately removed after a quote string > quoted string.

    A new line is added after the quote message which later got deleted using below code

        formatTextForQuote(regex, textToCheck, replacement) {
            if (textToCheck.match(regex)) {
                // Remove '>' and trim each line of quote content
                let textToFormat = textToCheck.split('\n').map(row => row.substr(4).trim()).join('\n'); <====== trim is happening here
    
                // Remove leading and trailing line breaks
                textToFormat = textToFormat.trim();
                return replacement(textToFormat);
            }
            return textToCheck;
        }

    Input string given to modifyTextForQuote function

        &gt; quote\n# heading
    

    so after parsing the text following output is retuned.

    <blockquote>quote</blockquote># heading

    Now heading regex is looking for # on start of line as below which does not match string <blockquote>quote</blockquote># heading hence it fails to parse heading tag

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

    1. Move heading1 rule to be before quote
    2. Modify heading1 rule to not capture the newline: /^# +(?! )((?:(?!<pre>|\n|\r\n).)+)/gm
    3. Add new rule replaceh1br that repalces <br /> next to <h1> tag
    {
          // We're removing <br /> because when <h1> and <br /> occur together, an extra line is added.
          name: 'replaceh1br',
          regex: /<\/h1><br\s*[/]?>/gi,
          replacement: '</h1>',
    },

    Output generated for a given input

    Input: '> quote\n# heading'
    Output: '<blockquote>quote</blockquote><h1>heading</h1>'
    
    
    Input: `> a\n# da\n> test`
    Output: '<blockquote>a</blockquote><h1>da</h1><blockquote>test</blockquote>'
    
    
    Input: `>This is a *quote* that started on a new line.\n# Heading 1 should be captured\nHere is a >quote that did not\n`
    Output '<blockquote>This is a <strong>quote</strong> that started on a new line.</blockquote><h1>Heading 1 should be captured</h1>Here is a &gt;quote that did not<br />'
    Additional inputs tested ```text > quote # heading > quote ```
    > quote
    # heading
    > quote # heading 
     quote
    
    > quote
    # heading
    > quote # heading 
     quote 
    # heading
    
    > quote
    # heading
    > quote
    
    # heading after 2 lines
    > quote 
    # heading
    
    > quote
    # heading
    > quote #heading
    # heading
    > quote 
    # heading
    `
         
    ```text
    > DFFDS
    # FDS
    *FDDSF*
    # SDSAF ~SFASDF~
    > quote 
    # heading
    
    > quote
    # heading
    > quote # heading
    
    # heading
    # heading
    > quote
     #heading
    > quote
    #heading
    # heading
    

    What alternative solutions did you explore? (Optional)

    1. Modify modifyTextForQuote function in order to add new line char when heading is next after the blockquote. It'll let heading rule to parse heading tag as-is
          // check if next text chunk is  heading tag i.e. starts with #  then append new line char \n
          if (Str.startsWith(textSplitted[i], "# ") )
          {
              replacedText = `${replacedText}\n`
          }

    After adding \n, parsed output is <blockquote>quote</blockquote><br /><h1>heading</h1> where unnecessary br tag is added between blockquote and h1

    1. Add a new rule to check if a <br /> occurs between blockquote and h1 then remove <br /> tag (we got similar rules replacebr, replacepre). After processing this rule final output is <blockquote>quote</blockquote><h1>heading</h1>.
    Code changes required:
       // check if next text chunk is  heading tag `starts with # ` then append new line char \n
       if (Str.startsWith(textSplitted[i], "# ") )
       {
          replacedText = `${replacedText}\n`
       }
       {
          // We're removing <br /> because when <br /> occur between <blockquote> and <h1>, causing an extra line is added.
          name: 'replaceBlockquoteBr',
          regex: /<\/blockquote><br\s*[/]?><h1>/gi,
          replacement: '</blockquote><h1>',
       }

    Since newline rule replaces \n with <br />. So regex can modified as <\/blockquote><br\s\/><h1>

  7. spcheema commented on Jun 28, 2023

    @spcheema
    Contributor

    @kbecciv It actually a bug that went unnoticed. Kindly read through the root cause mentioned in my proposal and you will have an idea why it’s happening.
    Heading regex expects ‘#’ on start of the line which never gets captured.

  8. 90 remaining items

  9. melvin-bot commented on Jul 14, 2023

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  10. melvin-bot commented on Jul 14, 2023

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.40-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2023-07-21. 🎊

    After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

    • External issue reporter
    • Contributor that fixed the issue
    • Contributor+ that helped on the issue and/or PR

    As a reminder, here are the bonuses/penalties that should be applied for any External issue:

    • Merged PR within 3 business days of assignment - 50% bonus
    • Merged PR more than 9 business days after assignment - 50% penalty
  11. melvin-bot commented on Jul 14, 2023

    @melvin-bot

    BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

    • [@s77rt] The PR that introduced the bug has been identified. Link to the PR:
    • [@s77rt] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
    • [@s77rt] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
    • [@s77rt] Determine if we should create a regression test for this bug.
    • [@s77rt] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
    • [@conorpendergrast] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  12. spcheema commented on Jul 15, 2023

    @spcheema
    Contributor

    @conorpendergrast @s77rt Please consider following timings for bonus eligibility:

    Action Timing
    Issue assigned 2023-07-06T23:43:37Z
    E\Common PR up for review 2023-07-08T05:31:21Z
    C++ approved 2023-07-08T11:25:07Z
    PR merged 2023-07-10T20:31:41Z
    E\APP PR up for review 2023-07-10T22:12:45Z
    C++ approved 2023-07-11T05:33:17Z
    PR merged 2023-07-12T16:43:13Z

    After C++ reviewed & approved, following timeline is waiting for internal reviewer to approve and merge the PR.

    1. Waiting time for E\Common PR approval & merge: 2 days 9 hours 6 minutes 34 seconds

    2. Waiting time for E\APP PR approval & merge: 1 days 11 hours 9 minutes 56 seconds

    Total waiting time (internal & merge): 3 days 20hrs approx.

    Total time elapsed from issue assigned to second PR merged: 5 days 16 hours 59 minutes 36 seconds

  13. s77rt commented on Jul 15, 2023

    @s77rt
    Member
  14. conorpendergrast commented on Jul 21, 2023

    @conorpendergrast
    Contributor

    I will check in on is one, and confirm before paying. I'm OoO on Monday and Tuesday, and will be back to this on Wednesday 26th with confirmation

  15. melvin-bot commented on Jul 25, 2023

    @melvin-bot

    @cead22, @conorpendergrast, @s77rt, @spcheema Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  16. cead22 commented on Jul 26, 2023

    @cead22
    Contributor

    Not overdue per @conorpendergrast 's update above

  17. conorpendergrast commented on Jul 26, 2023

    @conorpendergrast
    Contributor

    @cead22 and I agree with an exception here as the C and C+ acted with urgency.

    Everyone has been paid accordingly, and contracts ended. We're all done, thanks!

  18. spcheema commented on Jul 26, 2023

    @spcheema
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions