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

[QUESTION] - Markdown square-bracket links

Open Michota opened this issue 10 months ago • 4 comments

Am I doing something wrong, or the parser simply does not support the inner links ([[filename]]) syntax? If I understand correctly, the ExpansiMark does in fact follow this syntax, right? That's how I understand this regex:

const MARKDOWN_LINK_REGEX = new RegExp(`\\[([^\\][]*(?:\\[[^\\][]*][^\\][]*)*)]\\(${UrlPatterns.MARKDOWN_URL_REGEX}\\)(?![^<]*(<\\/pre>|<\\/code>))`, 'gi');

If not, can I implement this function by modyfing parseExpensiMark.ts, or do I need to dig under the hood, in the ExpansiMark itself?

Is there any tutorial or documentation article which would guide me how to add custom syntaxes for markdown?

Michota avatar Mar 06 '25 00:03 Michota

Hi @Michota, as far as I know ExpensiMark doesn't support [[filename]] syntax. When it comes to links, ExpensiMark supports regular links (like https://example.com) and labeled links (like [label](https://example.com)).

Perhaps it would be the best to implement it directly in expensify-common (most likely as a patch in your app because it's unlikely that this will be merged into main). Alternatively, you can do some preprocessing in parseExpensiMark.ts. I'm afraid currently there are no tutorials on how extend Markdown syntax, though.

Keep in mind that you can also implement your own Markdown parser (it must be workletized, though) and pass it to parser prop in MarkdownTextInput, see the example in README: https://github.com/Expensify/react-native-live-markdown?tab=readme-ov-file#parsing-logic

tomekzaw avatar Mar 06 '25 08:03 tomekzaw

@Michota Just wanted to ask, do you use react-native-live-markdown with the New Architecture enabled?

We're considering dropping support for the old architecture since Expensify uses this library only on the new architecture and we don't really maintain the old implementation for Paper.

tomekzaw avatar Mar 07 '25 15:03 tomekzaw

Weird thing: I have newArchEnabled=true setting set in graddle.properties, and i set { "expo": { "newArchEnabled": true } } yet when I console.log(global?.nativeFabricUIManager) it returns false, which suggest, that I use Paper... or maybe I am doing something wrong?

Michota avatar Mar 07 '25 20:03 Michota

@Michota Try global.RN$Bridgeless

tomekzaw avatar Mar 07 '25 21:03 tomekzaw