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

Unify the blockquote parsing logic for messages and rawInput #820

Conversation

Skalakid
Copy link
Contributor

@Skalakid Skalakid commented Nov 18, 2024

This PR changes and unifies the blockquote parsing logic for the NewDot messages and the Live Markdown Input. Currently, the parsing result is different when the shouldKeepRawInput variable is true. Thanks to the changes in this PR, the results are consistent (visually). The only difference is that the tags are being grouped when shouldKeepRawInput=false.

Example:

> test
>> test
> test

NewDot sent message shouldKeepRawInput=false

<blockquote>test<br /><blockquote>test</blockquote>test</blockquote>

Live Markdown Input shouldKeepRawInput=true

<blockquote> test</blockquote>
<blockquote><blockquote> test</blockquote></blockquote>
<blockquote> test</blockquote>

Also, it's worth mentioning that new blocquote parsing rules has been discussed here and now the following cases are parsed:

Valid blocquote examples 
> test
> 
>> test
>>> test
> # heading

Invalid blocquote examples 
> > test last ">" shouldn't be parsed as a blocquote)
> >> test (last ">>" shouldn't be parsed as a blocquote)
>> > test (last ">" shouldn't be parsed as a blocquote)
>>>> test (last ">" shouldn't be parsed as a blocquote)
># heading

Fixed Issues

$ Expensify/App#45154
$ Expensify/App#47951

Tests

  1. Applying changes to both the NewDot app and the Live Markdown Input
  2. Verify if the markdown is the same when writing the message and after sending it

QA

Same as Tests

@Skalakid Skalakid force-pushed the @Skalakid/fix-blockquote-formatting branch from 17c5562 to a1511ab Compare November 22, 2024 16:51
@Skalakid Skalakid marked this pull request as ready for review November 27, 2024 08:42
@pecanoro pecanoro self-requested a review November 27, 2024 15:27
@Pujan92
Copy link
Contributor

Pujan92 commented Nov 28, 2024

commenting for the assignment.

@Skalakid
Copy link
Contributor Author

Skalakid commented Dec 2, 2024

Hi @pecanoro, can you assign @Pujan92 to review this PR please?

@pecanoro
Copy link
Contributor

pecanoro commented Dec 2, 2024

Hmm for some reason I can't add him tot he issue even if he commented

lib/ExpensiMark.ts Outdated Show resolved Hide resolved
lib/ExpensiMark.ts Outdated Show resolved Hide resolved
lib/ExpensiMark.ts Show resolved Hide resolved
lib/ExpensiMark.ts Outdated Show resolved Hide resolved
@Skalakid Skalakid requested a review from pecanoro December 4, 2024 09:41
@Pujan92
Copy link
Contributor

Pujan92 commented Dec 4, 2024

@Skalakid I am trying to link this commit in E/App but facing some issue while running the app. Wondering how you connected and tested in E/App?

@Skalakid
Copy link
Contributor Author

Skalakid commented Dec 4, 2024

@Pujan92 expensify-common commits can't be linked to the E/App, but you can add my changes by running npm i and then npm run build in the expensify-common repo. After this, copy the JS code from the /dist/ExpensifyMark.js file into the /node_modules/expensify-common/dist/ExpensiMark.js file in NewDot

@Pujan92
Copy link
Contributor

Pujan92 commented Dec 5, 2024

@Skalakid Isn't the message here should be the same as of live markdown input(Applied a space between 2 blockquotes)?

Screen.Recording.2024-12-05.at.15.55.53.mov

@Skalakid
Copy link
Contributor Author

Skalakid commented Dec 5, 2024

@Pujan92 Oh, I forgot to tell you one more detail to set up the testing environment, sorry 😅 You must also apply these ExpensiMark changes inside the Live Markdown Library. To do that, you have to:

  1. Clone react-native-live-markdown repo
  2. Go to the @Skalakid/fix-blockquote-formatting branch. I've updated and committed changes for ExpensiMark inside Live Markdown parser
  3. Run yarn install
  4. yarn prepare
  5. yarn pack - it will generate a packed Live Markdown library file that you can install in the NewDot App
  6. Go to the NewDot repo, and in the console, run npm i -S <path_to_the_previously_generated_tgz_file>
  7. Run npm i

And now you will have new parsing logic applied both in the NewDot and Live Markdown libraries :D

@Skalakid
Copy link
Contributor Author

Skalakid commented Dec 5, 2024

Also, it's worth mentioning here that new rules for the blockquote has been discussed here and now this "> > >" won't be parsed as a nested blocquote

@Skalakid
Copy link
Contributor Author

Skalakid commented Dec 5, 2024

I updated the PR description with new rules explanation

@pecanoro
Copy link
Contributor

pecanoro commented Dec 5, 2024

@Pujan92 I can't assign you for review to this PR but let me know when you have tested it and you can just leave a LGTM and I will merge it!

Copy link
Contributor

@Pujan92 Pujan92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks @Skalakid!

@pecanoro pecanoro merged commit b0ab52a into Expensify:main Dec 5, 2024
6 checks passed
@os-botify
Copy link
Contributor

os-botify bot commented Dec 5, 2024

🚀 Published to npm in 2.0.109 🎉

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

Successfully merging this pull request may close these issues.

3 participants