Commits

Anonymous committed 44511e9

Initial revision

  • Participants

Comments (0)

Files changed (1)

File adrian/website/HTMLindex.pl

+#! /usr/local/bin/perl
+#
+# Adrian Aichner, Teradyne GmbH. Munich, Sat, May. 06 1995.
+#
+
+use Getopt::Long;
+
+main();
+
+sub main {
+    my (@cmd_line) = ($0, @ARGV);
+    my(@index);
+    my($data_pat) = 
+	".*?((\\bnot\\s+)?\\b[-\\w]+(ed|ing|sion|tion|ould|ate)|are|on|from|with|we)\\b.*";
+    my($heading, $name, $data, $hstart, $hend);
+    while (<>) {
+	#
+	# Perform line-oriented actions below.
+	#
+	if (m|(<H[1-6][^>]*>)(.*)(</H[1-6]>)|) {
+	    $hstart = $1;
+	    $heading = $2;
+	    $hend = $3;
+	    # Remove HTML-markup (needs more work to handle HTML ATTRIBUTES).
+	    $_ = $heading;
+	    $_ =~ s/<[^>]+>//g;
+	    # Match a work in Heading somewhat meaningful as a hyper-link.
+	    m|$data_pat|i;
+	    $data = $1;
+	    # Build unique link-target by using first letter of each word in HEADING.
+	    $name = $_;
+	    $name =~ s/(\w)\w*/$1/g;
+	    $name =~ s/\W+//g;
+	    # Incorporate the link-target into the current line, which is a HEADING.
+	    # Create an index-line, containing a hyper-link to this HEADING.
+	    $index = $_;
+	    $index =~ s|$data\b|<A HREF="#$name">$data</A>|;
+	    # push the index-line onto the index-stack to be dumped before </BODY>.
+	    push @index, $index;
+	    # Re-assemble HEADING.
+	    $_ = $hstart . $_ . $hend;
+	    $_ .= "\n<P><A HREF=\"\#index\">Goto</A> Index</P>\n";
+	    s|$data\b|<A NAME="$name">$data</A>|;
+	}
+	if (m|<ADDRESS>|) {
+	    print "<P>This <A NAME=\"index\">index</A> was generated by @cmd_line</P>\n<UL>\n";
+	    for (@index) {
+		print "<LI><P>$_</P></LI>\n";
+	    }
+	    print "</UL>\n<HR>\n";
+	}
+	print;
+	if (eof) {
+	    close (ARGV);
+	}
+    }
+}
+