Annotation of doc/help/texxml2latex.pl, revision 1.2

1.1       bowersj2    1: #!/usr/bin/perl
                      2: 
1.2     ! bowersj2    3: # The LearningOnline Network with CAPA
        !             4: # Converts a texxml file into a single tex file
        !             5: #
        !             6: # Copyright Michigan State University Board of Trustees
        !             7: #
        !             8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
        !             9: #
        !            10: # LON-CAPA is free software; you can redistribute it and/or modify
        !            11: # it under the terms of the GNU General Public License as published by
        !            12: # the Free Software Foundation; either version 2 of the License, or
        !            13: # (at your option) any later version.
        !            14: #
        !            15: # LON-CAPA is distributed in the hope that it will be useful,
        !            16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
        !            17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        !            18: # GNU General Public License for more details.
        !            19: #
        !            20: # You should have received a copy of the GNU General Public License
        !            21: # along with LON-CAPA; if not, write to the Free Software
        !            22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
        !            23: #
        !            24: # /home/httpd/html/adm/gpl.txt
        !            25: #
        !            26: # http://www.lon-capa.org/
        !            27: #
        !            28: # 7-16-2002 Jeremy Bowers
        !            29: 
1.1       bowersj2   30: use strict;
                     31: use HTML::TokeParser;
                     32: use GDBM_File;
                     33: 
                     34: # accept texxml document on standard in
                     35: my $p = HTML::TokeParser->new( $ARGV[0] );
                     36: my $dirprefix = "/home/httpd/html/adm/help/tex/";
                     37: 
                     38: # Print the header
                     39: open (LATEX_FILE, $dirprefix . "Latex_Header.tex");
                     40: print <LATEX_FILE>;
                     41: 
                     42: 
                     43: while (my $token = $p->get_token())
                     44: {
                     45:     my $type = $token->[0];
                     46:     if ($type eq 'S')
                     47:     {
                     48: 	my $tag = $token->[1];
                     49: 	my $attr = $token->[2];
                     50: 	if ($tag eq 'section')
                     51: 	{
                     52: 	    my $title = $attr->{'name'};
                     53: 	    print "\\section{$title}\n\n";
                     54: 	}
                     55: 
                     56: 	if ($tag eq 'subsection')
                     57: 	{
                     58: 	    my $title = $attr->{'name'};
                     59: 	    print "\\subsection{$title}\n\n";
                     60: 	}
                     61: 
                     62: 	if ($tag eq 'subsubsection')
                     63: 	{
                     64: 	    my $title = $attr->{'name'};
                     65: 	    print "\\subsubsection{$title}\n\n";
                     66: 	}
                     67: 
                     68: 	if ($tag eq 'file')
                     69: 	{
                     70: 	    my $file = $attr->{'name'};
                     71: 	    open (LATEX_FILE, $dirprefix . $file);
                     72: 	    print <LATEX_FILE>;
                     73: 	}
                     74: 
                     75: 	if ($tag eq 'tex')
                     76: 	{
                     77: 	    print "\n";
                     78: 	    print $attr->{'content'};
                     79: 	    print "\n";
                     80: 	}
                     81:     }
                     82: }
                     83: 
                     84: # Print out the footer.
                     85: open (LATEX_FILE, $dirprefix . "Latex_Footer.tex");
                     86: print <LATEX_FILE>;

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