react-native-live-markdown icon indicating copy to clipboard operation
react-native-live-markdown copied to clipboard

Ordered and unordered lists

Open robinmitra opened this issue 1 year ago • 4 comments

Thank you for your work on this library!

Do you have any plans for implementing ordered and unordered lists?

robinmitra avatar Jun 10 '24 21:06 robinmitra

Hello and thanks for opening this issue.

Do you have any plans for implementing ordered and unordered lists?

Currently, we don't support ordered and unordered lists. This is mostly because currently the library uses a hard-coded Markdown parser called ExpensiMark and it does not have this feature.

However, in the future, library users will be able to pass custom Markdown parser and use custom styles for formatting so theoretically this should be possible.

If you need this feature now, I think it should be pretty straightforward to extend this library in terms of Markdown parser as well as on the native side. If you need any guidance, I could provide you exact steps how to do that.

I will keep you updated on that.

tomekzaw avatar Jun 11 '24 07:06 tomekzaw

Thanks for coming back to me, yes I think I'd like some guidance on extending this library for supporting these feature. Appreciate the help 🙌🏼

robinmitra avatar Jun 12 '24 05:06 robinmitra

Sure! First you'll need to make changes in the JS parser here: https://github.com/Expensify/react-native-live-markdown/blob/main/parser/index.ts There's a function called parseExpensiMarkToRanges that accepts a string with the message and returns an array of styled ranges. Don't forget to bundle the code with yarn build and test it with yarn test.

Once that's complete, you'll need to implement the actual styling logic on the native side.

For iOS, you'll need to edit this file: https://github.com/Expensify/react-native-live-markdown/blob/457a90c4756182ebca62edc468a5f803e666e25f/ios/RCTMarkdownUtils.mm#L97-L136

For Android, you'll need to make changes here: https://github.com/Expensify/react-native-live-markdown/blob/457a90c4756182ebca62edc468a5f803e666e25f/android/src/main/java/com/expensify/livemarkdown/MarkdownUtils.java#L105-L168

FYI We also offer consulting services, so if you need some more help with extending this library, we'd be more than happy to do so, just drop us a line at [email protected].

tomekzaw avatar Jun 12 '24 13:06 tomekzaw

Thank you! I'll give it a try this weekend.

robinmitra avatar Jun 21 '24 08:06 robinmitra