Content last modified Tuesday 24 August 2021
hop to #bottom
Author:
Jukka Svahn
About It:
Rate it:
  • Helpful?
  • 0 Yes
  • 1 No
Flag it:

If you'd like to provide updated information and do not have access to directly edit, please contact the site admin; thanks!

rah_urltolink

Rah_urltolink has been dropped and in some ways superceded along the years. The plugin always used a simple regular expression which really doesn’t need it’s own plugin. The same can be done using other great, newer and existing tools, including rah_function and pax_grep.

For those interested in modifying and parsing markup, there are also tools even better available, like for instance etc_query. Unlike regular expression based solutions, etc_query can understands the actual markup structure and can do dynamic modification reliably since the plugin uses xPath.

For general linking needs there is also adi_link and of course built-in link tags.

Nonetheless, the old downloads are still available here.

The things that rah_urltolink did, or does, are directly doable in any plugin that can run regular expression. The results are same, or should say, as limiting as far as markup goes. The following would turn any word instance that resembles a link to a HTML link. This plainly searches for certain protocols (http, https, ftp, ftps) and tries to end the link in the correct position:

<txp:rah_function call="preg_replace" pattern="#([>\s\A]+)(((http://|https://|ftp://|ftps://)([a-zA-Z0-9-]+\.){0,}([a-zA-Z0-9-\./\_\?\%\#\&\=\;\~\!\(\)]+))([^?\s<>,.!]))#" replacement="$1<a href=""$2"">$0</a>" thing="here">
	<p>Some content with http://www.example.com/ here.</p>
</txp:rah_function>

Doesn’t really work with complex markup, it can create links in wrong places and can eat content or cut too early. If you do use it, please try to use it for a plain-text as you might have done with rah_urltolink too. The same limitation do apply.

Moving on from URLs, to link any what-seems-to-be a email address as a mailto link:

<txp:rah_function call="preg_replace" pattern="#([>\s\A]+)((([a-zA-z0-9-\.]+@[a-zA-z0-9-\.]+)([a-zA-Z0-9-\./\_\?\%\#\&\=\;\~\!\(\)]+))([^?\s<>,.!]))#" replacement="$1<a href=""mailto:$2"">$0</a>" thing="here">
	<p>Some content with some emails like some@email.com that here.</p>
</txp:rah_function>

Please keep in mind that just like the original plugin, these are regular expressions. Which is one of the reasons why the plugin is dropped. It doesn’t serve the purpose well. Regular expressions do not care and are rather complicated to get even remotely to play well with HTML markup that isn’t exactly regulated or follow certain limited patterns.

Article Request Count:

Archived [?]: dropped, superseded

Keywords/tags:
Posted here:
30 Oct 2008

You know you want to visit the Archives.
Published with Textpattern