X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/sw-tools/blobdiff_plain/961ce1c2fa0e71e5ffc0c16a1d4fa58802a36a1c..fae2108b8a8d45ebef4d49fcb0964453c2be32a7:/perl/SWDoc.pm
diff --git a/perl/SWDoc.pm b/perl/SWDoc.pm
index d87da58..aeedb04 100644
--- a/perl/SWDoc.pm
+++ b/perl/SWDoc.pm
@@ -1,6 +1,6 @@
# -*-perl-*-
#
-# $Id: SWDoc.pm,v 1.1 1999/07/30 18:46:37 mdw Exp $
+# $Id: SWDoc.pm,v 1.3 1999/08/19 12:11:09 mdw Exp $
#
# Display documentation files
#
@@ -28,6 +28,12 @@
#----- Revision history -----------------------------------------------------
#
# $Log: SWDoc.pm,v $
+# Revision 1.3 1999/08/19 12:11:09 mdw
+# More improvements to URL recognizer.
+#
+# Revision 1.2 1999/08/18 17:10:07 mdw
+# Slight improvements to URL and email address parsing.
+#
# Revision 1.1 1999/07/30 18:46:37 mdw
# New CGI script for browsing installed software and documentation.
#
@@ -56,12 +62,38 @@ sub doc {
while (my $line = $fh->getline()) {
last if $line =~ //;
$line =~ s/\&/&/g;
- $line =~ s/\</g;
- $line =~ s/\>/>/g;
- $line =~ s!(http|ftp)://[^]&)\s]*[^]&).,\s\']!$&!g;
- $line =~ s!info:([^]&)\s]*[^]&).,\s\'\"])!$&!g;
- $line =~ s![^\s()&;{}.,\`\"][^\s()&;{}\`\"]*\@[^\s()&;{}\'\"]*[^\s()&;{}.,\'\"]!$&!g;
- $line =~ s!([-_.\w]+)\((\d+\w*)\)!SWMan::subst("$1($2)", $1, $2)!eg;
+ $line =~ s/\</>>/g;
+
+ # --- Spot URLs (except `mailto') ---
+
+ $line =~ s! \b (http s? | ftp | file | news) :
+ [^])\s<>]* [^]<>&).,\s\']
+ !SWMan::urlsubst($&, $&)!egx;
+
+ # --- Spot email addresses (including `mailto' URLs) ---
+
+ $line =~ s! (?:\bmailto:)?
+ ([^\s()&;:<>&{}.,\`\'\"] [^\s()&;:<>&{}\`\'\"]*
+ \@
+ [^\s()&;:{}<>&\'\"]* [^\s()&;:{}<>&.,\'\"])
+ !$&!gx;
+
+ # --- Spot info references ---
+
+ $line =~ s! \b info: ([^]&)\s<>]* [^]&).,\s<>\'\"])
+ !$&!gx;
+
+ # --- Spot manpage references ---
+
+ $line =~ s! ([-_.\w]+) \( (\d+\w*) \)
+ !SWMan::subst("$1($2)", $1, $2)!egx;
+
+ # --- Finally fix up the HTML properly ---
+
+ $line =~ s/\<\;\</g;
+ $line =~ s/\>\>\;/>/g;
+
print $line;
}
print "\n";