Skip to content

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

@ronaldwind

Description

@ronaldwind

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

text: ~r{^[\s\S]+?(?=~~|[\\<!\[_*`#{subsup}]|https?://| \{2,\}\n|$)}
which results in the PureLinkHelpers not converting it into a link.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions