Expensify/react-native-live-markdown

Quotes inside codeblocks removes all formatting

Closed this issue · 5 comments

Description

When using MarkdownTextInput the written text is formatted properly. However, when pasting some markdown text, the pasted text is not formatted. Even if I erase and type again, the text formatting does not update.

I didn't find if its intentional, but I believe its not, so I opened the issue.

Platform

This bug is on Android. I can't check if its present on other platforms.

Other details

React Native version: 0.73.4
@expensify/react-native-live-markdown version: 0.1.5
Android's version: 13
JS Engine: Hermes
Archtecture: Old

@viniciusyoshioka Thanks for opening this issue. Would you be able to share with us a screen recording that shows the problem so we have a better understanding on how to reproduce it?

@tomekzaw Yes, sure!

https://github.com/Expensify/react-native-live-markdown/assets/71671043/52ee9a5e-b6a8-4121-ba94-4ea3df15b672
Screen recording 1

https://github.com/Expensify/react-native-live-markdown/assets/71671043/9998bb19-584c-4a29-96dd-1627090427b0
Screen recording 2

In "Screen recording 1", I reproduced the problem. After typing some markdown text, I paste another text and then the formatting is not applied in the whole component.

While recording, I realized something that can be a real bug, and recorded it in "Screen recording 2". The formatting seems to be working fine, even when pasting text, I'm sorry for not testing more before.

But I found what is causing this. Having single or double quotes inside code block (the one with 3 backticks), removes the whole formatting. After erasing the quotes from inside the code block, the formatting returns.

@viniciusyoshioka Thank you very much for preparing the screen recordings and your investigation.

You are right, there is a bug in parsing blockquotes if they contain characters like ", ', & and some others.

If there is a bug while parsing Markdown, we simply remove all formatting. This also helps us identify such cases.

I believe this has been already adressed by @robertKozik, we will submit a PR with a fix. Thank you!

Hi @viniciusyoshioka Once again thanks for reporting this issue! The issue is indeed inside the parser, as to be more precise data inside the codeblock was escaped twice - which was breaking our checks. That leads to remove the formatting.

This PR should resolve this problem: #140

Hi @robertKozik!

I have tested the pull request with every character available in my keyboard and it is working perfectly.

Thank you @tomekzaw and @robertKozik for the quick fix!