- $out =~ s!\b(https?|ftp|file|news):[^]&)\s]*[^]&).,\s\'\"]!<a href="$&">$&</a>!g;
- $out =~ s!(?:\bmailto:)?([^\s()&;:{}.,\`\"][^\s()&;:{}\`\"]*\@[^\s()&;:{}\'\"]*[^\s()&;:{}.,\'\"])!<a href="mailto:$1">$&</a>!g;
- $out =~ s!([-_.\w]+)\((\d+\w*)\)!SWMan::subst("$1($2)", $1, $2)!eg;
+ # --- Spot URLs (except `mailto') ---
+
+ $out =~ s! \b (http s? | ftp | file | news) :
+ [^]<>)\s]* [^]<>).,\s\']
+ !urlsubst($&, $&)!egx;
+
+ # --- Spot email addresses (including `mailto' URLs) ---
+
+ $out =~ s! (?:\bmailto:)?
+ ([^\s()<>&;:{}.,\`\'\"] [^\s()<>&;:{}\`\'\"]*
+ \@
+ [^\s()<>&;:{}\'\"]* [^\s()<>&;:{}.,\'\"])
+ !<a href="mailto:$1">$&</a>!gx;
+
+ # --- Spot manpage references ---
+
+ $out =~ s! ([-_.\w]+) \( (\d+\w*) \)
+ !SWMan::subst("$1($2)", $1, $2)!egx;
+
+ # --- Fix up the HTML ---
+
+ $out =~ s/\<\</</g;
+ $out =~ s/\>\>/>/g;