Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: [dropped] rah_urltolink
hola jukka,
concerning your last update:
Fixed: Now URLs right after (X)HTML tags (> char), dots, and so on, are turned into links: No more requires appending space. Even link middle of a word is turned into link.
is this still in the code, or did you throw it out so as to not convert links that are already wrapped in [a]-tags?
could i switch this on again, by modifying the code?
cheers from germany,
thx for the great plugin!!
-f
Offline
Re: [dropped] rah_urltolink
funtoosh wrote:
is this still in the code, or did you throw it out so as to not convert links that are already wrapped in [a]-tags?
Yep. It just doesn’t work.
could i switch this on again, by modifying the code?
Probably. Removing the tab and space (the line 62) from the regular expression should do it.
Last edited by Gocom (2010-02-05 15:36:28)
Offline
Re: [dropped] rah_urltolink
damn … this really is pretty complicated ;—(
(wouldn’t it be possible to convert links not after every >
, but only after <br />
and <p>
?
mhm, might be too complex though …)
best, -f
Offline
Re: [dropped] rah_urltolink
I’m having an issue with v0.4.4.
URLs next to a >
aren’t converted into links.
Test cases:
<h2>www.google.com</h2>
<p>http://example.com</p>
Putting a leading space (ie. between >
and the URL) will make rah_urltolink to do its magic, but it’s not a desired workaround.
I tried this fix:
$content = preg_replace(
"/".
- "(^| | )".
+ "(^| | |>)".
"(".$ereg.")".
"(([a-zA-Z0-9-]+\.)+".
"[a-zA-Z0-9-\.\/\_\?\%\#\&\=\;\~\!\(\)]+)/e",
"rah_urltolink_build(\"$1\",\"$2\",\"$3\",\"$link\",\"$label\",\"$0\")"
,
' '.$content.' '
and it seems to work fine for me.
As in the plugin changelog there are one or two mentions about this (see changelog for 0.4.4, 0.4.3 and 0.4), it surprised me that I’ve to explicitly add the >
to the regex to fix it. Am I missing anything?
Offline
Re: [dropped] rah_urltolink
Oh, it seems there is an unreleased WIP (looks like a refactored version) here…
Offline
Re: [dropped] rah_urltolink
maniqui wrote:
Am I missing anything?
If you do that it will add links inside any tag, including links itself, buttons, options, select fields and so. That’s the reason why it doesn’t add links right after a closing tag. Plus links don’t have a real set end, which makes it eat stuff too.
looks like a refactored version
Yep, but that has issues. Those same as above. I wouldn’t use it in production where clients add the content.
Don’t want to scare but consider that as a “maybe never coming out” or deprecated. Rah_urltolink is one of those I want to drop and find a better alternative. The plugin is uninteresting, shouldn’t exist. It has wrong approach, too much issues. Creating auto-linker requires way-more-code. Tons more – or something else than regular expressions.
Regular expressions as the name suggests are regulated, while a markup language is not. If you do use the plugin, please try to avoid wrapping markup inside the rah_urltolink as much as possible. I can admit that it will most certainly break. To make the plugin work with a markup even in the sightliest, the code should be broken into multiple segments, a regular expression that select the nodes that can be modified as done in common hackish markup compressors.
To be honest, I would recommend looking at other alternatives than this for such usage cases if you want to ensure valid markup. Like for instance something that actually parses XML/HTML markup and understands it. This plugin’s super simple regex doesn’t really even need a plugin, but a mere regular expression run from a rah_function would suffice, I suppose. E.g.
<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">
Some content with text links as http://www.example.com/. Some content here.
</txp:rah_function>
Which does the same stuff. It doesn’t automatically highlight www. or emails as those would require conditions, if a single regex is needed. But you could just use separate instances rather than callbacks, which would also allow writing a more proper email regex too. The one used by the plugin is way too incorrect.
Last edited by Gocom (2012-08-27 03:56:06)
Offline
Re: [dropped] rah_urltolink
Gocom wrote:
If you do that it will add links inside any tag, including links itself, buttons, options, select fields and so. That’s the reason why it doesn’t add links right after a closing tag. Plus links don’t have a real set end, which makes it eat stuff too.
If I got you right, you mean cases like <a href="http://example.com">http://example.com</a>
, correct?
In any case, thanks for the feedback. I think I’ll revert to using Textile’s self-links (or whatever it is called) syntax: "$":
Offline
Offline