Took the above regexps and turned them into a BBedit text filter.

   - Save the Perl script below into "~/Library/Application 
   Support/BBEdit/Text Filters/Convert URL and email to links.pl"
   - In Terminal: chmod 755 '~/Library/Application Support/BBEdit/Text 
   Filters/Convert URL and email to links.pl'
   - In BBEdit, select the text you want to convert (e.g. the whole 
   document), and select Text > Apply Text Filter > Convert URL and email to 
   links.pl



#!/usr/bin/perl -w
# Filter to add tags around web links (starting with http:// or www.) and
# email addreses.
# Known issues: will double-convert (i.e. will add tags around web addresses
# already in tags).

use strict;

my $input = '';
while (<>) {
$input .= $_;
}

# Convert web URLs to href links
$input =~ 
s|\b(([\w-]+://?\|www[.])[^\s()<>]+(?:\([\w\d]+\)\|([^[:punct:]\s]\|/)))|<a 
href="$1">$1</a>|g;

# Convert email addresses to mailto links
$input =~ 
s/((?:[\w\-\.]+)@(?:(\[([0-9]{1,3}\.){3}[0-9]{1,3}\])|(([\w\-]+\.)+)([a-zA-Z]{2,4})))/<a
 
href="mailto:$1";>$1<\/a>/g;

# Remove http://http://
$input =~ s/href\s*=\s*"(?![[:alnum:]\/]*?:)/href="http:\/\//g;

# Spit it back out
print "$input";

On Tuesday, May 17, 2011 1:38:23 PM UTC-7, Bo wrote:
>
> How does one convert email and web addresses to hyperlinks using 
> BBEdit. 
>
> Thanks in advance.

-- 
-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to