auto_link function, after any Markdown processing.
There are all sorts of reasons to not want to have to use a silly syntax for adding simple links — mine was that my content gets distributed out to other services and it’s easier to make autolinking better than to remove the autolink syntax for the syndicated copies.
The fix is fairly simple:
- Find the
doAutoLinks($text)function (or whatever function processes auto links in your version of Markdown). In PHP Markdown Extra, it’s on line 1443.
Find following regex:
This is the one that identifies links specified with the
- Add a question mark (e.g. ‘?’) after each of the ‘
<’s and ‘
- Ta-daa! You can now use either plain links or surround them with angle brackets and they’ll be converted to
<a>tags as usual.
How this works
The regex in markdown searches for a URI surrounded by angle brackets. By adding a question mark after each of the angle brackets you’re specifying that the preceding character should be matched zero or more times — i.e. that it is optional.
Therefore, the following syntaxes now work (and coincidentally are recommended reading on the topics covered in this article):