Admin/website/build/mkcontents.pl
changeset 16233 e634d33deb86
equal deleted inserted replaced
16232:8a12e11d222b 16233:e634d33deb86
       
     1 #!/usr/bin/perl
       
     2 
       
     3 # mkcontents.pl
       
     4 #
       
     5 #   $Id$
       
     6 #
       
     7 #   simple script to create a html version of the Contents file in the
       
     8 #   Isabelle documentation directory.
       
     9 #
       
    10 #   Nov/14/1999 Version 1.0  -  Gerwin Klein <kleing@in.tum.de>
       
    11 #
       
    12 #   command line:
       
    13 #   mkcontent.pl [-p <url-path-prefix>] <Content-file> <output-file>
       
    14 #
       
    15 
       
    16 
       
    17 use Getopt::Long ;
       
    18 
       
    19 $opt_p="";
       
    20 $result = GetOptions ("p=s");
       
    21 
       
    22 $path=$opt_p;
       
    23 
       
    24 $infile  = $ARGV[0];
       
    25 $outfile = $ARGV[1];
       
    26 
       
    27 $listHeader = "<ul>\n";
       
    28 $lineHeader = "  <li>";
       
    29 $lineEnd    = "</li>\n";
       
    30 $listFooter = "</ul>\n";
       
    31 
       
    32 $topicStart = "<h3>";
       
    33 $topicEnd   = "</h3>\n";
       
    34 
       
    35 open(IN, "<$infile") || die "cannot read input file <$infile>";
       
    36 open(OUT, ">$outfile") || die "cannot write output file <$outfile>";
       
    37 
       
    38 $first = 1;
       
    39 
       
    40 print OUT '<?xml version="1.0" encoding="iso-8859-1" ?>' . "\n";
       
    41 print OUT '<dummy:wrapper xmlns:dummy="http://nowhere.no">' . "\n";
       
    42 
       
    43 while (<IN>) {
       
    44   if (/^([^ \t].*)\n/) {
       
    45     if ($first == 1) {
       
    46       $first = 0;
       
    47     }
       
    48     else {
       
    49       print OUT $listFooter;
       
    50     }
       
    51     print OUT $topicStart;
       
    52     print OUT $1;
       
    53     print OUT $topicEnd;
       
    54     print OUT $listHeader;
       
    55   }
       
    56   elsif (/^[ \t]+([^ \t]+)[ \t]+(.+)\n/) {
       
    57     print OUT $lineHeader;
       
    58     print OUT "<a target='_blank' href='$path$1.pdf'>$2</a>";
       
    59     print OUT $lineEnd;
       
    60   }
       
    61 }
       
    62 
       
    63 print OUT $listFooter;
       
    64 
       
    65 print OUT '</dummy:wrapper>' . "\n";
       
    66 
       
    67 close(OUT);
       
    68 close(IN);
       
    69 
       
    70 exit(0);