Open jlgrall opened 10 years ago
I guess that could work as an option. There's still some thinking to do to figure out a good URL detection pattern though.
It might be easier to look at an already existing Firefox extension or Greasemonkey extension that does URL autolinking for webpages in the browser.
Noting this for reference: http://daringfireball.net/2010/07/improved_regex_for_matching_urls
+1 like. It would be handy for content writers.
+1
I'm suggesting the following URL detection pattern.
function doAutoLinks($text)
{
...
$text = preg_replace_callback("/((http|https|ftp):\/\/\S+[^\'\"\,\.\;\:\s]+)/", array(&$this, "_doAutoLinks_url_callback"), $text);
$text = preg_replace_callback("/([\w\-\.]+@[\w\-\.]+\.[\w]{2,4})/", array(&$this, "_doAutoLinks_email_callback"), $text);
return $text;
}
Another PHP regex for matching the URL patterns → http://jmrware.com/articles/2010/linkifyurl/linkify.html
I would be interested in this feature as well. Typically, it would take the form of an autolink
boolean flag on the MarkdownExtra
class that enables/disables autolinking URLs in paragraphs.
The reason why this operation is desirable inside the Markdown parser is that it is neither practical to do it before nor after the Markdown conversion because URLs can be present inside tags, attributes, etc... and shouldn't be converted.
It is a problem for us over at friendica/friendica
because we receive Markdown texts from Diaspora* that's using RedCarpet for displaying their message, and the RedCarpet markdown parser has an autolink feature, which allows Diaspora users to leave URLs as is in paragraphs to be transformed in HTML links.
Consequently, when we receive such Markdown text in Friendica, users are expecting to see the resulting post the same way it looked on Diaspora, with the URLs transformed in HTML links.
I've found another PHP Markdown parser library that has an autolinker feature (https://github.com/erusev/parsedown-extra) but I'd prefer to stick with this one as we are familiar with it and we don't know if they support the same options as yours.
I would also like to see this! It is kind of annoying that I have to first pre-process my markdown to turn bare links into markdown links in order to support this.
Please, add an option to allow automatic linking of the URLs in texts even when they are not surrounded by angle brackets.
See URL autolinking in Github Flavored Markdown.
See extension
autolink_bare_uris
in Pandoc.