noties / Markwon

Android markdown library (no WebView)
https://noties.io/Markwon/
Apache License 2.0
2.68k stars 298 forks source link

Using both markdown support and regular link clicking support #420

Closed boldijar closed 1 year ago

boldijar commented 1 year ago

Expected behavior: I can see both markdown links and regular links

Actual behavior: I can only click markdown links

Let's say we have this text:

# header
## smaller headet

My favorite search engine is [Duck Duck Go](https://duckduckgo.com).

And simple link https://duckduckgo.com

I would like to be able to see both links and click them. With no textview configuration only the markdown links work, and If I add

            android:autoLink="web"

To the textview, I will only be able to click the plain URL from the last line.

Is there a way to be able to support both?

shenck commented 1 year ago

I have the same issue and would love for this to be supported. To work around the problem, I ended up converting the simple links to markdown links before I load the view. Something similar to the below.

val pattern = "(?<!\\]\\()(http[s]{0,1}:\\/\\/[a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-zA-Z]{2,6}\\b([-a-zA-Z0-9@:%_\\+.~#?&\\/=]*))"
markdown = markdown.replace(Regex(pattern), "[\$1](\$1)")
noties commented 1 year ago

Hello @boldijar , @shenck ,

default Android android:autoLink XML attribute and code removes any other links from markdown text. You can use LinkifyPlugin (from linkify artifact)