[BACK]Return to list2html.pl CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / htdocs

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /htdocs/Attic/list2html.pl between version 1.1 and 1.2

version 1.1, 1999/03/29 19:43:01 version 1.2, 1999/04/23 01:53:05
Line 4 
Line 4 
 # Process *.faq files into indexed *.html files. (abs)  # Process *.faq files into indexed *.html files. (abs)
 # Looks for these compulsary tags:  # Looks for these compulsary tags:
 #       <SECTION>Text           Introduces a new section (before first <ENTRY>)  #       <SECTION>Text           Introduces a new section (before first <ENTRY>)
 #       <DATE>tag date Text     Change entry, expanded to title & added to list  
 #       <ENTRY>tag Text         New entry, expanded to title and added to list  
 #       <ENTRYLINK>url Text     Link added to list, removed from main text  
 #       <LIST>                  Include generated list of entries here.  #       <LIST>                  Include generated list of entries here.
 #       <ENDLIST>               Optional tag for end of all special entries  #       <ENDLIST>               Optional tag for end of all special entries
 #  #
 # Plus these optional tags:  # Plus these optional tags:
   #       <DATE>tag date Text     Change entry, expanded to title & added to list
   #       <ENTRY>tag Text         New entry, expanded to title and added to list
   #       <ENTRYLINK>url Text     Link added to list, removed from main text
 #       <HEADING>Text           Standard heading at top of document  #       <HEADING>Text           Standard heading at top of document
 #       <BASELINKS>             Standard links at base of document  #       <BASELINKS>             Standard links at base of document
 #  #
Line 71  sub makefaq
Line 71  sub makefaq
     {      {
     my($infile,$outfile,%extras)=@_;      my($infile,$outfile,%extras)=@_;
     my($data,$section,$href,$header,$list,$pre,%tags,$date_month);      my($data,$section,$href,$header,$list,$pre,%tags,$date_month);
     my($date_num,$date_num_used,$entry_num,$ignore);      my($date_num,$date_num_used,$entry_num,$ignore,$in_entry,$endlist);
   
     $list="      $list="
 <!-- THIS FILE GENERATED FROM '$infile'.  <!-- THIS FILE GENERATED FROM '$infile'.
Line 86  sub makefaq
Line 86  sub makefaq
         {          {
         if( defined($pre) )          if( defined($pre) )
             { $_=$pre.$_; $pre=undef; }              { $_=$pre.$_; $pre=undef; }
   
         if( substr($_,-2) eq "\\\n" )          if( substr($_,-2) eq "\\\n" )
             {              {
             s/\\\n$//;              s/\\\n$//;
Line 97  sub makefaq
Line 98  sub makefaq
             {              {
             my($year,$month,$link);              my($year,$month,$link);
   
               if ($in_entry)
                   {
                   $data.="</dd></dl></p>\n";
                   $in_entry=undef;
                   }
             $ignore=undef;              $ignore=undef;
             ++$date_num;              ++$date_num;
             $header=$1;              $header=$1;
             if( $header !~ /^([-a-z0-9_.+]+)\s+(\d+ (\S+ \d+) - (\S.*))/ )              if( $header !~ /^([-a-z0-9_.+]+)\s+(\d+) (\S+) (\d+) - (\S.*)/ )
                 { &fail("'$header' not in expected 'date - event' format"); }                  { &fail("'$header' not in expected 'date - event' format"); }
             $href=$1;              $href=$1;
             $header=$2;              $header="$5 ($2 $3)";
             $month=$3;              $month="$3 $4";
             $link=$4;              $link=$5;
             if( defined($tags{$href}) )              if( defined($tags{$href}) )
                 { &fail("Duplicate name tag '$href'"); }                  { &fail("Duplicate name tag '$href'"); }
             $tags{$href}=1;              $tags{$href}=1;
Line 113  sub makefaq
Line 119  sub makefaq
                 { $ignore=1; }                  { $ignore=1; }
             else              else
                 {                  {
                   $_='';
                 ++$date_num_used;                  ++$date_num_used;
                 if( $month ne $date_month )                  if( $month ne $date_month )
                     {                      {
                     if( $date_month ne '' )                      if( $date_month ne '' )
                         { $list.="</ul>\n"; }                          { $list.="</ul>\n"; }
                     $list.="<h3>$month</h3>\n<ul>\n";                      $list.="<h3>$month</h3>\n<ul>\n";
                       $_.="<hr><h2>$month</h2><hr>\n";
                     $date_month=$month;                      $date_month=$month;
                     }                      }
   
                 $_ = "<hr><h3><a name=\"$href\">$header</a> <font size=\"-1\">".                  $_.= "<p><dl><dt>\n".
                                     "(<a href=\"#top\">top</a>)</font></h3>\n";                          "<h3><a name=\"$href\">$header</a> <font size=\"-1\">".
                           "(<a href=\"#top\">top</a>)</font></h3>\n</dt><dd>";
                 $list.="<li><a href=\"#$href\">$link</a></li>\n";                  $list.="<li><a href=\"#$href\">$link</a></li>\n";
                 }                  }
               $in_entry=1;
             }              }
         elsif( m#^<ENTRYLINK>\s*(.+\S)# )  
             {  
             $ignore=undef;  
             ++$entry_num;  
             if( !defined($section) )  
                 { &fail("<ENTRYLINK> before <SECTION> tag"); }  
             $_=$1;  
             if( ! m#^(\S+)\s+(.*)# )  
                 { &fail("Invalid <ENTRYLINK> ($_), not (\S+)\s+(.*)"); }  
             $href=$1;  
             $header=$2;  
   
             $_ = '';  
             $list.="<li><a href=\"$href\">$header</a></li>\n";  
             &verbose("\t$href\n");  
             }  
         elsif( m#^<ENTRY>\s*(.+\S)# )          elsif( m#^<ENTRY>\s*(.+\S)# )
             {              {
               if ($in_entry)
                   {
                   $data.="</dd></dl></p>\n";
                   $in_entry=undef;
                   }
   
             $ignore=undef;              $ignore=undef;
             ++$entry_num;              ++$entry_num;
             if( !defined($section) )              if( !defined($section) )
Line 158  sub makefaq
Line 159  sub makefaq
                 { &fail("Duplicate name tag '$href'"); }                  { &fail("Duplicate name tag '$href'"); }
             $tags{$href}=1;              $tags{$href}=1;
   
             $_ = "<hr><h3><a name=\"$href\">$header</a>\n<font size=\"-1\">".              $_ = "<p><dl><dt>\n".
                                     "(<a href=\"#top\">top</a>)</font></h3>\n";                      "<h3><a name=\"$href\">$header</a>\n<font size=\"-1\">".
                       "(<a href=\"#top\">top</a>)</font></h3>\n</dt><dd>\n";
             $list.="<li><a href=\"#$href\">$header</a></li>\n";              $list.="<li><a href=\"#$href\">$header</a></li>\n";
               $in_entry=1;
             &verbose("\t$href\n");              &verbose("\t$href\n");
             }              }
   
           elsif( m#^<ENTRYLINK>\s*(.+\S)# )
               {
               $ignore=undef;
               ++$entry_num;
               if( !defined($section) )
                   { &fail("<ENTRYLINK> before <SECTION> tag"); }
               $_=$1;
               if( ! m#^(\S+)\s+(.*)# )
                   { &fail("Invalid <ENTRYLINK> ($_), not (\S+)\s+(.*)"); }
               $href=$1;
               $header=$2;
               $_ = '';
               $list.="<li><a href=\"$href\">$header</a></li>\n";
               &verbose("\t$href\n");
               }
   
         elsif( m#^<SECTION>\s*(.+\S)# )          elsif( m#^<SECTION>\s*(.+\S)# )
             {              {
               if ($in_entry)
                   {
                   $data.="</dd></dl></p>\n";
                   $in_entry=undef;
                   }
             $ignore=undef;              $ignore=undef;
             if( defined($section) )              if( defined($section) )
                 { $list.="</ul>\n"; }                  { $list.="</ul>\n"; }
             $section=$1;              $section=$1;
             $list.="<h2>$section</h2>\n<ul>\n";              $list.="<h2>$section</h2>\n<ul>\n";
             $_="<hr>\n<h2>$section</h2>";              $_="<hr>\n<h2>$section</h2><hr>";
             &verbose("    $section\n");              &verbose("    $section\n");
             }              }
   
         elsif( m#^<ENDLIST># )          elsif( m#^<ENDLIST># )
             {              {
               if ($in_entry)
                   {
                   $data.="</dd></dl></p>\n";
                   $in_entry=undef;
                   }
               if ($endlist)
                   { &fail("Duplicate <ENDLIST>"); }
               $endlist=1;
             $ignore=undef;              $ignore=undef;
             $_='';              $_='';
             }              }
   
         if( ! $ignore )          if( ! $ignore )
             {              {
             s#([\w.+]+)\((\d)\)#<a href="http://www.flame.org/cgi-bin/uncgi/hman/$1;$2">$1($2)</a>#g;              s#([\w.+]+)\((\d)\)#<a href="http://www.flame.org/cgi-bin/uncgi/hman/$1;$2">$1($2)</a>#g;
Line 187  sub makefaq
Line 222  sub makefaq
   
     close(FILE);      close(FILE);
     $list.="</ul>\n";      $list.="</ul>\n";
     if( $data !~ s/<LIST>/$list/ )      if (!$endlist)
           { &fail("Missing <ENDLIST> tag"); }
       if ($data !~ s/<LIST>/$list/)
         { &fail("Unable to locate <LIST> tag"); }          { &fail("Unable to locate <LIST> tag"); }
     open(FILE,">$outfile") || die("Unable to write '$outfile': $!");      open(FILE,">$outfile") || die("Unable to write '$outfile': $!");
     print FILE &extras_process($data,%extras);      print FILE &extras_process($data,%extras);
Line 210  sub extras_generate
Line 247  sub extras_generate
   
     if( $0 !~ m#(.*)/[^/]+.pl# )      if( $0 !~ m#(.*)/[^/]+.pl# )
         { &fail("Unable to extract path from '$0'"); }          { &fail("Unable to extract path from '$0'"); }
     $pathtodoc=$1;      $pathtodoc="$1/Documentation";
     foreach $str ( keys %extras )      foreach $str ( keys %extras )
         {          {
         $extras{$str} =~ s#\$HOME#$pathtodoc/..#g;          $extras{$str} =~ s#\$HOME#$pathtodoc/..#g;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

CVSweb <webmaster@jp.NetBSD.org>