bagder: curl-www/docs faqparse.pl,1.4,1.5

[email protected]
Newsgroups gmane.comp.web.curl.www.cvs
Message-ID <[email protected]>
Update of /cvsroot/curl/curl-www/docs
In directory labb:/tmp/cvs-serv18258

Modified Files:
	faqparse.pl 
Log Message:
make fancier names to make URLs that include the first part of the title
for specific faq entries


Index: faqparse.pl
===================================================================
RCS file: /cvsroot/curl/curl-www/docs/faqparse.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- faqparse.pl	25 Nov 2004 14:21:45 -0000	1.4
+++ faqparse.pl	30 Jul 2007 12:34:13 -0000	1.5
@@ -35,7 +35,8 @@
                     print "\n<p>\n";
                     $o = $s;
                 }
-                printf "<a href=\"faq.html#%s\">%s</a> %s<br>\n", $_, $_, $faq{$_};
+                printf "<a href=\"faq.html#%s\">%s</a> %s<br>\n",
+                $link{$_}, $_, $faq{$_};
             }
 
             print "<hr>\n";
@@ -46,6 +47,16 @@
             my ($num, $phrase)=($1, $2);
 #            print "$num $phrase\n";
             $faq{$num} = $phrase;
+            my $l = substr($phrase, 0, 32);
+            # filter off "odd" chars
+            $l =~ s/[^a-z0-9A-Z]/_/g;
+            # filter off trailing underscores
+            $l =~ s/_+\z//;
+            # filter off initial underscores
+            $l =~ s/^_+//;
+            # filter off multiple underscores
+            $l =~ s/_+/_/g;
+            $link{$num} = $l;
             push @toc, $num;
         }
         elsif($_ =~ /([0-9])\. (.*)/) {
@@ -72,6 +83,8 @@
             my $s=$_;
             chomp $s;
             $s =~ s/^ *(.*) */$1/;
+            print "<a name=\"$link{$toc[$q]}\"></a>";
+            # we provide the older name as well to make oldish links live
             print "<a name=\"$toc[$q]\"></a><h3>$s</h3><p>\n";
             $q++;
         }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.