-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[HOLD for payment 2023-11-30] [$2000] Newline is removed from code block with a character before it #16982
Comments
Triggered auto assignment to @twisterdotcom ( |
Bug0 Triage Checklist (Main S/O)
|
Job added to Upwork: https://www.upwork.com/jobs/~01a8161082bc95b676 |
Current assignee @twisterdotcom is eligible for the External assigner, not assigning anyone new. |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @0xmiroslav ( |
Triggered auto assignment to @PauloGasparSv ( |
ProposalPlease re-state the problem that we are trying to solve in this issue.The ``` is at the same line as | when we write it in a different line. We wanted to make it still in their own line. What is the root cause of that problem?In Markdown, the | symbol is used to separate columns in a table, and it is not intended to have a line break when it is copied and pasted. When you copy and paste a table created in Markdown, the | symbol is used to indicate the boundaries between columns, and it is preserved in the copied text. What changes do you think we should make in order to solve the problem?We need to manually check if this symbol exists and add a What alternative solutions did you explore? (Optional)Reminder: Please use plain English, be brief, and avoid jargon. Feel free to use images, charts, or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job. There are several libraries out there to handle this problem, but it requires more changes in the code and I didn't recommend this method. |
Please re-state the problem that we are trying to solve in this issue. What is the root cause of that problem? What changes do you think we should make in order to solve the problem? Solution video Complete |
📣 @JMGCode! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Format:
|
Contributor details |
✅ Contributor details stored successfully. Thank you for contributing to Expensify! |
ProposalPlease re-state the problem that we are trying to solve in this issue.Two issues need to solve
What is the root cause of that problem?Click to see RCA of the first issueFrom Web(Chrome/Safari), when we copy message through ctrl/cmd+c, we set html selection to clipboard here. We send following two new comments to dig the root cause
like We add a log before this line and copy the above message through ctrl/cmd+c. The selection html is shown as below If we paste in composer, then we convert html to markdown here HTML selection <comment><div>| </div><pre><span>code</span></pre></comment> is converted into markdown | ```
code
``` While HTML selection <comment><div>A </div><pre><span>code</span></pre></comment> is converted into markdown A
```
code
``` To figure out why the pipe The above is the RCA of copy and paste issue for pipe Let's move forward to dig the line break issue in editing mode. As the line break missing issue in editing mode is same for having pipe
We translate markdown text into html here and save following message html to backend. A <pre>code<br /></pre> When replacing markdown to html, we remove the line break after When editing a sent message, we call htmlToMarkdown to convert message html to markdown text here. The message html of above sent comment is A <pre>code<br /></pre> which is much simpler than the html actually rendered in the page. In method htmlToMarkdown, the above message html is translated into following markdown text by applying newline rule and codeFence rule.
The root cause is the way we translate codefence from markdown-to-html and from html-to-markdown. When digging the root cause, I went through this closed issue #12783 which explains the root cause and ends up do nothing. What changes do you think we should make in order to solve the problem?To fix the first issue for pipe To fix the second issue, we can improve the regex rule to translate The key idea is to sort out cases before the The improved regex rule will look like {
name: 'codeFence',
// We use to (<\/(\w+)>| )? to capture the closing tag or a space before <pre> tag
// if g1 is undefined then the prefix is empty string
regex: /(<\/(\w+)>| )?<(pre)(?:"[^"]*"|'[^']*'|[^'">])*>([\s\S]*?)(\n?)<\/\3>(?![^<]*(<\/pre>|<\/code>))/gi,
replacement: (match, g1, g2, g3, g4) => {
let prefix = '';
if (g1) {
if (g1 === ' ') {
// We're using a trick to handle line break before <pre> tag, see 'replacebr' rule. It's like a magic to make line break between <pre> behave consistently on Web and native platforms. Note that only text copied from Expensify App has space before <pre> tag.
// see https://meliorence.github.io/react-native-render-html/api/renderhtmlprops#enableexperimentalbrcollapsing
// see https://github.com/Expensify/App/blob/91e2120e647aa9ee22171b6dbb772b4aebe64992/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.js#L16
prefix = '\n';
} else if (/div|comment|h1|h2|h3|h4|h5|h6|p|li|blockquote/i.test(g2)) {
// We just add the closing block type tag back
prefix = `</${g2}>`;
} else {
// g1 is inline closing tag and we insert a line break after it
prefix = `</${g2}>\n`;
}
}
return `${prefix}\`\`\`\n${g4}\n\`\`\``;
},
} By doing so, we can pass all existing tests of Expensify-common and solve a bunch of twists related to this feature. What alternative solutions did you explore? (Optional)I also agree with @iwiznia to save the original text entered by user to solve this issue as he commented here. |
There are 2 issues with different root causes. |
I don't think we should consider fixing either anymore! I just checked all proposals and @eh2077 found an older issue from 2022 where we already discussed Case 2. It links to a discussion on slack we had on both bugs (it also mentions other discussions we had on those) and back then we decided to do nothing! here:
Because of that I think we should close the issue and not fix anything, ok @twisterdotcom? |
@PauloGasparSv that old issue was reported by me 🙂 and I was already aware of that . I double confirmed because it's stated in the issue description as Case 2. If we still don't wanna fix it, let's remove that case. |
Didn't notice that @0xmiroslav :D I think that both case 1 and case 2 were discussed in the slack threads linked by the issue you created (they mention pasting and editing)! So I think we should fix nothing here as we already discussed both cases and nothing changed, does that make sense? |
@PauloGasparSv makes sense, but that was old discussion. Can you confirm again on slack before close? Here's inconsistency issue: when select text before copy and without select inconsistency.mov |
Regardless whether we want to handle the 2nd issue, I think we should handle the 1st case as it's only happening to |
@PauloGasparSv Thanks for reviewing proposals! But I think we should at least fix this regex demonstrated by case 1 as the pipe |
Personally, I think we should line break always at the start and end of code block. No reason we should do nothing despite of inconsistency between start and end, | and other characters, copy with selection and from context menu. |
@twisterdotcom I think we should fix the first case about the pipe Hmm, do I have luck to get some compensation for investigating the issue as @PauloGasparSv mentioned in comment #16982 (comment) ? |
I've sent an offer of $250 as a bonus for the investigation @eh2077. Thanks for your work on this here. |
@twisterdotcom thanks for the offer! Accepted. |
@cead22 @twisterdotcom To elaborate, when the content is initially copied from an external resource such as GitHub, World, CodeEditor, etc. This content is in HTML format, which is then converted to Markdown so that the user can edit it in the composer. When the user submits the edited content, it is then converted back to HTML, when editing we again use HTML to markDown display markdown again in Composer. During the editing process, the content goes through multiple conversions between HTML and Markdown, which can introduce bugs and issues that affect the editing experience. For example, if there is a bug in the conversion process from HTML to Markdown when editing, this bug will also appear in the initial conversion from HTML to Markdown (when copying from another resource). In my proposal, I identified that the root cause of the issue was that we were not considering code blocks as inline blocks, unlike other inline-block elements. We already have a function to handle most inline blocks, and we can easily modify this function to include code blocks as well in one line. |
@ahmdshrif thanks for the input, but I'm not sure I fully understand it. If you want to continue the discussion, can you perhaps rephrase the first 3 paragraphs and use concrete examples to illustrate your point? Specifically around the following statements
As for the one below, seeing as we've agreed that if the edited version produces the same HTML as the original then that's fine, what are you defining here as "the issue"?
|
In general:
In our example here:
here test, when I copy between Expensify and GitHub, shows why the new line can change markdown. Screen.Recording.2023-05-14.at.12.23.31.PM.movwhat do you think? @cead22 |
re: the in general section, it seems like we're still talking about hypotheticals, so it's hard to engage with those points without having concrete examples re: the video you're showing, perhaps that's where the disconnect is. IMO, we care that the resulting HTML is the same in new dot, not in any other app. |
@cead22 What do you think about the opposite case? when copying this case from another resource to a new dot do we care about it? Screen.Recording.2023-05-16.at.2.50.22.PM.movIn Markdown, we should add the ``` in a separate line to create a code block; otherwise, it will be rendered as text. What is the reason for using different Markdown rules? here is a test of rendering code block with and without text before triple backticks : Screen.Recording.2023-05-16.at.3.17.10.PM.mov |
Can you ask these in #expensify-open-source? |
I encountered this issue a few days ago, it's happening with all the text, not excluded to |
I think this should be re-opened. |
Can we wait on the outcome of the investigation in #18928? I don't think we should double up work here. |
@twisterdotcom In #18928, they didn't fix the real root cause but applied workaround |
26490 |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.2-3 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-11-30. 🎊 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.
For reference, here are some details about the assignees on this issue:
|
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:
|
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:
|
Case 1:
This only happens with | character
Case 2:
This happens to all character
Expected Result:
```
should be on its own lineActual Result:
` is at the same line as | because the newline is removed
Workaround:
unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Version Number: 1.2.95-0
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
Screen.Recording.2023-04-05.at.12.39.34.mov
Recording.142.mp4
Expensify/Expensify Issue URL:
Issue reported by: @bernhardoj
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1680669746873359
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: