File:  [LON-CAPA] / doc / help / texxml2indextex.pl
Revision 1.2: download - view: text, annotated - select for diffs
Fri Aug 9 14:48:31 2002 UTC (21 years, 8 months ago) by bowersj2
Branches: MAIN
CVS tags: version_0_99_2, version_0_99_1, version_0_99_0, version_0_6_2, version_0_6, version_0_5_1, version_0_5, conference_2003, HEAD
This should be all the help information necessary for the next stable
release.

    1: #!/usr/bin/perl
    2: 
    3: # The LearningOnline Network with CAPA
    4: # Converts a texxml file into an 'index' file suitable for use as a
    5: # help file online
    6: #
    7: # Copyright Michigan State University Board of Trustees
    8: #
    9: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
   10: #
   11: # LON-CAPA is free software; you can redistribute it and/or modify
   12: # it under the terms of the GNU General Public License as published by
   13: # the Free Software Foundation; either version 2 of the License, or
   14: # (at your option) any later version.
   15: #
   16: # LON-CAPA is distributed in the hope that it will be useful,
   17: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   18: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   19: # GNU General Public License for more details.
   20: #
   21: # You should have received a copy of the GNU General Public License
   22: # along with LON-CAPA; if not, write to the Free Software
   23: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   24: #
   25: # /home/httpd/html/adm/gpl.txt
   26: #
   27: # http://www.lon-capa.org/
   28: #
   29: # 7-16-2002 Jeremy Bowers
   30: 
   31: use strict;
   32: use HTML::TokeParser;
   33: use GDBM_File;
   34: 
   35: if (not defined($ARGV[1]))
   36: {
   37:     print <<USAGE;
   38: Usage: texxml2indextex.pl texxmlfilename
   39: texxml2indextex.pl will create an 'index file' suitable for use as a 
   40: sort of title page for a given set of help files. The second file will
   41: be placed at the beginning, verbatim, so it can be used to provide
   42: context, title, etc, if given.
   43: USAGE
   44: 
   45:    exit;
   46: }
   47: 
   48: # accept texxml document on standard in
   49: my $p = HTML::TokeParser->new( <$ARGV[1]> );
   50: my $dirprefix = "/home/httpd/html/adm/help/tex/";
   51: 
   52: # there's a TTH error if we put something before a section starts,
   53: # so don't display anything that precedes a section. Since that's just
   54: # the title page anyhow, no loss.
   55: my $inSection = 0;
   56: 
   57: while (my $token = $p->get_token())
   58: {
   59:     my $type = $token->[0];
   60:     if ($type eq 'S')
   61:     {
   62: 	my $tag = $token->[1];
   63: 	my $attr = $token->[2];
   64: 	if ($tag eq 'title')
   65: 	{
   66: 	    my $title = $attr->{'name'};
   67: 	    print "{\\Large Online Access to $title}\n\n";
   68: 	}
   69: 	if ($tag eq 'section')
   70: 	{
   71: 	    $inSection = 1;
   72: 	    my $title = $attr->{'name'};
   73: 	    print "\\emph{\\textbf{$title}}\n";
   74: 	    print "\\begin{itemize}\n\n";
   75: 	}
   76: 
   77: 	if ($tag eq 'subsection')
   78: 	{
   79: 	    my $title = $attr->{'name'};
   80: 	    print "\\textbf{$title}\n\n";
   81: 	    print "\\begin{itemize}\n\n";
   82: 	}
   83: 
   84: 	if ($tag eq 'subsubsection')
   85: 	{
   86: 	    my $title = $attr->{'name'};
   87: 	    print "\\emph{$title}\n\n";
   88: 	    print "\\begin{itemize}\n\n";
   89: 	}
   90: 
   91: 	if ($tag eq 'file')
   92: 	{
   93: 	    my $file = substr($attr->{'name'}, 0, -4);
   94: 	    my $title = $file;
   95: 	    $title =~ s/_/ /g;
   96: 	    if ($inSection) {print "\\item \\ref{$file} $title\n\n"};
   97: 	}
   98:     }
   99:     elsif ($type eq 'E')
  100:     {
  101: 	my $tag = $token->[1];
  102: 	if (index($tag, "section") != -1)
  103: 	{
  104: 	    print "\\end{itemize}\n\n";
  105: 	}
  106:     }
  107: }
  108: 
  109: print "\n\n\\end{document}\n\n";

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>