Annotation of doc/help/texxml2indextex.pl, revision 1.1
1.1 ! bowersj2 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: # accept texxml document on standard in
! 36: my $p = HTML::TokeParser->new( $ARGV[0] );
! 37: my $dirprefix = "/home/httpd/html/adm/help/tex/";
! 38:
! 39: if (not defined($ARGV[1]))
! 40: {
! 41: print <<USAGE;
! 42: Usage: texxml2indextex.pl texxmlfilename headerfile
! 43: texxml2indextex.pl will create an 'index file' suitable for use as a
! 44: sort of title page for a given set of help files. The second file will
! 45: be placed at the beginning, verbatim, so it can be used to provide
! 46: context, title, etc, if given.
! 47: USAGE
! 48: }
! 49:
! 50: # Print the specified header and title
! 51: print <$ARGV[1]>;
! 52:
! 53: while (my $token = $p->get_token())
! 54: {
! 55: my $type = $token->[0];
! 56: if ($type eq 'S')
! 57: {
! 58: my $tag = $token->[1];
! 59: my $attr = $token->[2];
! 60: if ($tag eq 'section')
! 61: {
! 62: my $title = $attr->{'name'};
! 63: print "\\emph{\\textbf{$title}}\n\n";
! 64: }
! 65:
! 66: if ($tag eq 'subsection')
! 67: {
! 68: my $title = $attr->{'name'};
! 69: print "\\textbf{$title}\n\n";
! 70: }
! 71:
! 72: if ($tag eq 'subsubsection')
! 73: {
! 74: my $title = $attr->{'name'};
! 75: print "$title\n\n";
! 76: }
! 77:
! 78: if ($tag eq 'file')
! 79: {
! 80: my $file = substr($attr->{'name'}, 0, -4);
! 81: my $title = $file;
! 82: $title =~ s/_/ /g;
! 83: print "\\item \\ref{$file} $title";
! 84: }
! 85: }
! 86: }
! 87:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>