Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-10-23 01:31:08

Gocom
Plugin Author
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,528
Website

[dropped] 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.

Last edited by Gocom (2012-08-31 07:15:26)

Offline

#2 2008-10-23 12:24:26

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,225
Website

Re: [dropped] rah_urltolink

Why couldn’t I find this when I needed it!

Offline

#3 2008-10-23 21:49:10

Gocom
Plugin Author
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,528
Website

Re: [dropped] rah_urltolink

Because released it publically yesterday. You could have asked (i got little library of self-made snippets) :D

Offline

#4 2008-10-23 21:55:48

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,225
Website

Re: [dropped] rah_urltolink

Offline

#5 2008-10-23 22:49:53

Gocom
Plugin Author
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,528
Website

Re: [dropped] rah_urltolink

Didn’t notice it, even when feeds inform me about new requests :P

Offline

#6 2008-10-24 00:39:09

Gocom
Plugin Author
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,528
Website

Re: [dropped] rah_urltolink

Version 0.2 released. Minor update to the code. Changelog:

  • Minor POSIX regular expression update: uses substrings instead of blasting whole string; avoids some faults.

More info and downloads

Offline

#7 2008-10-24 06:27:07

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: [dropped] rah_urltolink

Thanks Jukka,

very useful!

Offline

#8 2008-10-24 06:30:58

Gocom
Plugin Author
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,528
Website

Re: [dropped] rah_urltolink

masa wrote:

Thanks Jukka,
very useful!

Thank you masa :) “I love you and your kind words <3” :P

Last edited by Gocom (2008-10-24 06:31:32)

Offline

#9 2009-04-23 00:15:35

Gocom
Plugin Author
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,528
Website

Re: [dropped] rah_urltolink

A new version, 0.3, released. Changelog:

  • Fixed: Now “special chars”, including ?, &, (, ), won’t cut the URL.
  • Fixed: Now (X)HTML tags don’t get cut into the URL when a tag is located right after the URL.
  • Improved parsing speed.

More info and downloads

Offline

#10 2009-08-18 11:57:30

txpnisti
Member
Registered: 2009-02-25
Posts: 23

Re: [dropped] rah_urltolink

Hi Jukka! Any ideas: I write a comment with a link, like this:

The link is www.example.foo

After I click the preview button, the link itself seems to be alright, but the space between the link and previous word has disappeared, like this: The link iswww.example.foo

Now you can leave or fix the space thing. Save for the moderation. When the comment is studied in the moderation, the quotes in href seems to be converting “curly” ones presented with their numeric enties. (should be straight quotes but those are like 6 & 9) So if the comment now is made visible, link obviously is not working.

Offline

Board footer

Powered by FluxBB