Diff for /doc/help/texxml2latex.pl between versions 1.9 and 1.12

version 1.9, 2003/09/02 18:29:58 version 1.12, 2005/03/16 21:31:27
Line 36  use File::Temp; Line 36  use File::Temp;
 my $p = HTML::TokeParser->new( $ARGV[0] );  my $p = HTML::TokeParser->new( $ARGV[0] );
 my $dirprefix = "../../loncom/html/adm/help/tex/";  my $dirprefix = "../../loncom/html/adm/help/tex/";
   
   my $include_filenames = ($ARGV[1] eq '--with-filenames');
 # Make myself a temp dir for processing POD  # Make myself a temp dir for processing POD
 my $tmpdir = File::Temp::tempdir('loncapahelpgenXXXXXXX', TMPDIR => 1);  my $tmpdir = File::Temp::tempdir('loncapahelpgenXXXXXXX', TMPDIR => 1);
   
Line 43  my $tmpdir = File::Temp::tempdir('loncap Line 44  my $tmpdir = File::Temp::tempdir('loncap
 open (LATEX_FILE, $dirprefix . "Latex_Header.tex");  open (LATEX_FILE, $dirprefix . "Latex_Header.tex");
 print <LATEX_FILE>;  print <LATEX_FILE>;
   
   sub escape_latex {
       my ($string)=@_;
       $string=~s/\\/\\ensuremath{\\backslash}/g;
       $string=~s/([^\\]|^)\%/$1\\\%/g;
       $string=~s/([^\\]|^)\$/$1\\\$/g;
       $string=~s/([^\\])\_/$1\\_/g;
       $string=~s/\$\$/\$\\\$/g;
       $string=~s/\_\_/\_\\\_/g;
       $string=~s/\#\#/\#\\\#/g;
       $string=~s/([^\\]|^)(\~|\^)/$1\\$2\\strut /g;
       $string=~s/(>|<)/\\ensuremath\{$1\}/g; #more or less
   #    $string=&Apache::lonprintout::character_chart($string);
       # any & or # leftover should be safe to just escape
       $string=~s/([^\\]|^)\&/$1\\\&/g;
       $string=~s/([^\\]|^)\#/$1\\\#/g;
       $string=~s/\|/\$\\mid\$/g;
       return $string;
   }
   
 while (my $token = $p->get_token())  while (my $token = $p->get_token())
 {  {
     my $type = $token->[0];      my $type = $token->[0];
Line 51  while (my $token = $p->get_token()) Line 71  while (my $token = $p->get_token())
  my $attr = $token->[2];   my $attr = $token->[2];
  if ($tag eq 'section') {   if ($tag eq 'section') {
     my $title = $attr->{'name'};      my $title = $attr->{'name'};
     print "\\section{$title}\n\n";      print "\\section{".&escape_latex($title)."}\n\n";
  }   }
   
  if ($tag eq 'subsection') {   if ($tag eq 'subsection') {
     my $title = $attr->{'name'};      my $title = $attr->{'name'};
     print "\\subsection{$title}\n\n";      print "\\subsection{".&escape_latex($title)."}\n\n";
  }   }
   
  if ($tag eq 'subsubsection') {   if ($tag eq 'subsubsection') {
     my $title = $attr->{'name'};      my $title = $attr->{'name'};
     print "\\subsubsection{$title}\n\n";      print "\\subsubsection{".&escape_latex($title)."}\n\n";
  }   }
   
  if ($tag eq 'file') {   if ($tag eq 'file') {
     my $file = $attr->{'name'};      my $file = $attr->{'name'};
     open (LATEX_FILE, $dirprefix . $file) or       open (LATEX_FILE, $dirprefix . $file) or 
  ($! = 1, die "Can't find LaTeX file $dirprefix/$file; terminating build.");   ($! = 1, die "Can't find LaTeX file $dirprefix/$file; terminating build.");
       if ($include_filenames) {
    print "\\textrm{File: \\bf ".&escape_latex($file)."}\\\\\n";
       }
     print <LATEX_FILE>;      print <LATEX_FILE>;
     print "\n\n";      print "\n\n";
  }   }

Removed from v.1.9  
changed lines
  Added in v.1.12


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