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

[Tracking Issue] Implement HTML -> Markdown conversions in Expensimark #3047

Closed
10 tasks done
roryabraham opened this issue May 21, 2021 · 23 comments
Closed
10 tasks done
Assignees
Labels

Comments

@roryabraham
Copy link
Contributor

roryabraham commented May 21, 2021

Problem

Expensify.cash uses the Expensimark library in the expensify-common repo to convert markdown to HTML. That way, a user can compose a message using markdown, and it can be displayed + stored using HTML. However, when a user later goes to edit the message, we currently have no way to take the HTML and display it to them as markdown. We also don't want to store the original markdown in our database.

Why this is important

Editing comments is an important usability feature in Expensify.cash. However, we need to make sure that the edit-comment experience is as similar as possible to the original message composition experience.

Solution

Implement bi-directional HTML <---> Markdown conversion in Expensimark for all of the elements we currently support for Markdown ---> HTML conversion:

@roryabraham roryabraham changed the title [Tracking Issue] Implement HTML -> Markdown conversions in Expensimark [HOLD][Tracking Issue] Implement HTML -> Markdown conversions in Expensimark May 21, 2021
@roryabraham
Copy link
Contributor Author

HOLDing this on a POC PR over here. We might need to do an internal PR to update our other repos that also use Expensimark, depending on how we change the Expensimark interface.

@jasperhuangg
Copy link
Contributor

@roryabraham I was just thinking about this–and sorry if this has already been considered–but why don't we just store both the HTML and markdown versions of the report comment, and switch between the two for editing/copying report comments?

To minimize space, we can only store the HTML if the markdown and the HTML are identical (and default to it if the markdown version doesn't exist).

Feel like this would be a whole lot simpler than doing a bunch of string manipulation on HTML to make it look like markdown–we'd probably also avoid a bunch of bugs this way.

@parasharrajat
Copy link
Member

@jasperhuangg has raised a very good point. But I think it in another way. I would say that we should save the MD as I believe converting HTML to markdown will loose original MD markup which user entered.

And we can always convert the MD to HTML uniformly.

@roryabraham
Copy link
Contributor Author

I don't necessarily disagree @jasperhuangg, but this was discussed in slack here. If you'd like to reopen the discussion, I think Slack would be the best place for that so it gets better visibility. The reason we didn't go with that solution is that it will nearly double the amount of data we need to store in our largest table.

But @parasharrajat has introduced an interesting solution I don't believe was discussed before – only store the plain-text (markdown) version of a comment, then convert it to HTML only when needed.

@roryabraham
Copy link
Contributor Author

Raised the proposal to store only markdown in this slack thread.

@roryabraham
Copy link
Contributor Author

Moving forward with the original plan, I'm taking this off hold.

@roryabraham roryabraham changed the title [HOLD][Tracking Issue] Implement HTML -> Markdown conversions in Expensimark [Tracking Issue] Implement HTML -> Markdown conversions in Expensimark Jun 21, 2021
@roryabraham
Copy link
Contributor Author

For reference, this PR was merged as a POC, and it's being integrated into E.cash here.

@parasharrajat
Copy link
Member

@Jag96 We can mark finished tags on the list.

@Jag96
Copy link
Contributor

Jag96 commented Jul 14, 2021

Marked off the finished tags, left <br> unchecked and linked the bug we found

@parasharrajat
Copy link
Member

@Jag96 Let's open another issue for other tags. I see many complaints about it.

@isagoico
Copy link

isagoico commented Jul 20, 2021

Make hyperlinks editable in chat comments

Action Performed

  1. Send this a link using the hyperlink markdown to a conversation
  2. Click on edit the comment and save without making any changes

Expected result

Hyperlink markdown should be visible when editing the comment

Actual result

Hyperlink markdown is removed when editing the comment and then it's saved as plain text.

Notes/images/Video

Recording.198.mp4

From @joaniew https://expensify.slack.com/archives/C01GTK53T8Q/p1626810543044700

When I edit a chat that has a link to it already, the link turns into plain text and removes the hyper link, and I can’t edit it again to make it a link

@Jag96
Copy link
Contributor

Jag96 commented Jul 23, 2021

@parasharrajat it sounds like your proposal for #4169 will solve Hyperlink markdown is removed when editing the comment and then it's saved as plain text. right? If so, I'd like to hold off on adding the other HTML->MD conversions until the ones we currently support are behaving the way we expect them to.

@parasharrajat
Copy link
Member

parasharrajat commented Jul 23, 2021

@Jag96 No. That proposal fixes the content pasting by excluding not-needed tags. script & Style. Then it fixes the Html to MD parsing as unescaping the escaped Chars. Last point on the checklist Special characters (& currently looks like &amp when you go to edit a previously sent message with & in it) - Message Editing and pasting issues. #4169.

We are still lacking Link parsing. Until we have HTML to MD parser for links, Hyperlink markdown is removed when editing the comment and then it's saved as plain text will not be fixed. When we edit the message, Html is converted to MD. But currently it does not convert [link](url) links or email links.

@Jag96
Copy link
Contributor

Jag96 commented Jul 23, 2021

Ok sounds good, I'll make new issues then for each of the items in the checklist

@parasharrajat
Copy link
Member

@Jag96 Links and emails links can go into one. There will be one regex for both.

@roryabraham
Copy link
Contributor Author

  • Quote support implemented here, integrated into E.cash here
  • Inline code blocks added here, not yet integrated into E.cash, PR is here
  • We've had some proposals but no movement yet on hyperlinks and email links.

@roryabraham
Copy link
Contributor Author

Looks to me like everything except #4188 is done or almost done

@MelvinBot MelvinBot removed the Overdue label Aug 11, 2021
@parasharrajat
Copy link
Member

That is also done.

@roryabraham
Copy link
Contributor Author

roryabraham commented Aug 24, 2021

Looks like all the issues on our checklist are done here. I think I am going to ask Applause to do some extra QA here before we close this out and call it done.

@MelvinBot MelvinBot removed the Overdue label Aug 24, 2021
@roryabraham
Copy link
Contributor Author

Additional QA steps I would like to have done:

  1. Create a message with each of the markdown features in the issue description above.
  2. Attempt to edit the message. Verify that the markdown you entered when creating the message reappears in the edit box.
  3. Perform additional exploratory QA around editing messages containing markdown in New Expensify. Try to break it and let us know how it goes. 🙃

@roryabraham
Copy link
Contributor Author

QA requested in Slack

@roryabraham
Copy link
Contributor Author

Bumped Applause in slack here

@MelvinBot MelvinBot removed the Overdue label Sep 1, 2021
@roryabraham
Copy link
Contributor Author

Cool, actually Applause completed the exploratory testing we requested and exported these follow-up issues:

Since those are all being processed by our engineering pipeline independently, I think we can close this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants