pragdave / earmark

Markdown parser for Elixir
Other
859 stars 135 forks source link

Pure link feature does not support inline links without a protocol #487

Open ronaldwind opened 6 months ago

ronaldwind commented 6 months ago

The pure link converter does not seem to autolink URLs without a prefixed protocol.

I would expect the following four examples to all result in a link:

visit https://github.com
https://github.com
www.github.com
visit www.github.com

However, the last one is not automatically linked:

iex> Earmark.as_html("visit https://github.com")
{:ok, "<p>\nvisit <a href=\"https://github.com\">https://github.com</a></p>\n", []}

iex> Earmark.as_html("https://github.com")
{:ok, "<p>\n<a href=\"https://github.com\">https://github.com</a></p>\n", []}

iex> Earmark.as_html("www.github.com")
{:ok, "<p>\n<a href=\"http://www.github.com\">www.github.com</a></p>\n", []}

iex> Earmark.as_html("visit www.github.com")
{:ok, "<p>\nvisit www.github.com</p>\n", []}

As far as I can tell the last link is not detected by https://github.com/pragdave/earmark/blob/39a2045f7bc97969f66cabc1c0b0f822b742add4/lib/earmark_parser/context.ex#L116 which results in the PureLinkHelpers not converting it into a link.

flurin commented 5 months ago

Any news on this?

amit-chaudhari1 commented 5 months ago

Sorry for the delay, had minor health issues.

The quick workaround here would be very straight forward, but I'm working on implementing something that would work for the most common links like mailto: ftp, IPV4 and IPV6, along with the example they gave

Shall commit a fix over the weekend.

cometeer commented 4 weeks ago

Any update?