Commits

Anonymous committed 594bfc8

Added arguments to index headings and list seperately.
Add usage information (-h).

  • Participants
  • Parent commits 091e28b

Comments (0)

Files changed (1)

File adrian/website/HTMLindex.pl

     my(@index, $list_index);
     $list_index = 1;
     my($modifiers) = "(not?|m?any|all|much|little)";
-    my($word_ends) = "(able[rs]?|are|ed|ings?|ite|sions?|tions?|ould|ates?|izes?|ences?|ances?|ents?)";
+    my($word_ends) = "(able[rs]?|are|ed|ings?|ite|sions?|tions?|ould|ates?|izes?|[cd]es?|ances?|ents?|ers?)";
     my($words) = "(after|are|on|from|have|under|will|with|we)";
     my($data_pat) = 
 	".*?\\b(($modifiers\\s+)?\\b[-\\w]+$word_ends|$words)\\b.*";
     my($heading, $name, $data, $hstart, $hend);
+    if (! GetOptions("list", "headline")) {
+	usage();
+	exit 1;
+    }
+    if ($opt_help) {
+	usage();
+	exit 1;
+    }
     while (<>) {
 	#
 	# Perform line-oriented actions below.
 	if (m|<P><A HREF=\"\#index\"(\s+NAME[^>]*)?>Goto</A> Index</P>|) {
 	    next;
 	}
-	if (m|(<H[1-6][^>]*>)(.*)(</H[1-6]>)|i) {
+	if ($opt_headline && m|(<H[1-6][^>]*>)(.*)(</H[1-6]>)|i) {
 	    $hstart = $1;
 	    $heading = $2;
 	    $hend = $3;
 	    $_ .= "\n<P><A HREF=\"\#index\">Goto</A> Index</P>\n";
 	    s|$data\b|<A NAME="$name">$data</A>|;
 	}
-	if (/(<(D|O|U)L>)/i) {
+	if ($opt_list && /(<(D|O|U)L>)/i) {
 	    my($list_tag) = $1;
 	    s|$list_tag|<P><A HREF=\"\#index\" NAME="list$list_index">Goto</A> Index</P>\n$list_tag|;
 	    push @index, "<A HREF=\"\#list$list_index\">List</A> $list_index";
     }
 }
 
+sub usage {
+    printf("\n");
+    printf("Usage:\t$0 [-list] [-headline]\n");
+    printf("\n");
+    printf("Create an indexed version of the HTML input.\n");
+    printf("\n");
+    printf("\t[-l[ist]]\tInclude all HTML Lists in the index.\n");
+    printf("\t[-h]eadline]]\tInclude all HTML Headings in the index.\n");
+    printf("\n");
+}