Lasso Soft Inc. > Home

[text_to_url_LP6]

Linktext_to_url_LP6
AuthorAsle Benoni
CategoryString
Version6.x
Licensehttp://creativecommons.org/licenses/by/2.5/
Posted21 Feb 2006
Updated21 Feb 2006
More by this author...

Description

A simple tag to make URL and MAILTO: links from a text input or field.

Mail addresses are converted to <a href="mailto:foo@foo.com">foo@foo.com</a>. It searches for any links beginning with "www..." and converts them to <a href=> links. A link without "www" will also be clickable as long as it starts with "http://". Of course it cannot decide if a text like "blueworld.com" is a URL. The tag should guess all kinds of weird URLS.

If the text includes i.ex. <a href="http://bw.com">Click here</a> links it does not treat them since these are hardcoded already and you don't want to change them. It only treats obvious links that are not already clickable.

Option to choose whether or not to show "http://" in the link text.

Sample Usage

 Usage:
 text_to_url:'Please visit us at www.sample.com'
 -> Please visit us at http://www.sample.com

 text_to_url:'Please visit us at http://sample.com'
 -> Please visit us at http://sample.com

 text_to_url:'Please contact us at support@sample.com'
 -> Please visit us at suppport@sample.com

 If you want to leave out the "http://" in the link text you must change the value of local:'linktext'

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

 and if you keep the author information here ;-)
##
## A simple tag to make URL and MAILTO links from a text input or field.
## It searches for any links beginning with "www..." and converts them to  links.
## A link without "www" will also be clickable as long as there it starts with "http://"
## Of course it cannot decide if a text like "blueworld.com" is a URL.
## The tag should guess all kinds of weird URLS
## If the text includes i.ex. Click here links it does not treat them since 
## these are hardcoded already and you don`t want to change them. It only treats obvious links that
## are not already clickable.
## 
## Usage:
## text_to_url:'Please visit us at www.sample.com'
## -> Please visit us at http://www.sample.com
##
## text_to_url:'Please visit us at http://sample.com'
## -> Please visit us at http://sample.com
##
## text_to_url:'Please contact us at support@sample.com'
## -> Please visit us at suppport@sample.com
##
## If you want to leave out the "http://" in the link text you must change the value of local:'linktext'
##
#############################################################################################################
*/
						
define_tag: 'text_to_url_lp6', -Required='Field';

local:'urltext'= '';
local:'linktext'= '\\1';  // Change this value to '\\3' if you DO NOT want the link text to show a leading 'http://'

// First we change all "www.xx.xx" to "http://...."
#urltext = (String_ReplaceRegExp:#Field, -Find='((? Visit us "
#urltext=(String_ReplaceRegExp:#urltext, -Find='((?)(https?://|ftp://)((([A-Za-z0-9$_.+!*(),;/?:@&~=-])|%[A-Fa-f0-9]{2})+(#([a-zA-Z0-9][a-zA-Z0-9$_.+!*(),;/?:@&~=%-]*))?))', -Replace=''+ #linktext +'', -EncodeNone);

// Create email-links from found email
#urltext = (String_ReplaceRegExp:#urltext, -Find='([a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4})', -Replace=' \\1 ', -EncodeNone);

#urltext = (String_Replace: -Find='\n', -Replace='
\n', #urltext, -EncodeNone); return: @#urltext; /define_tag; //] ?>

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft