File:  [LON-CAPA] / loncom / xml / lontexconvert.pm
Revision 1.2: download - view: text, annotated - select for diffs
Thu May 3 22:54:12 2001 UTC (23 years, 1 month ago) by harris41
Branches: MAIN
CVS tags: HEAD
only need the pathname here

    1: # The LearningOnline Network with CAPA
    2: # TeX Conversion Module
    3: #
    4: # 05/29/00,05/30,10/11,10/20 Gerd Kortemeyer
    5: # 05/03/2001 Scott Harrison
    6: 
    7: package Apache::lontexconvert;
    8: 
    9: use strict;
   10: use tth;
   11: use vars qw($errorstring);
   12: use Apache::lonmsg;
   13: 
   14: # ====================================================================== Header
   15: 
   16: sub header {
   17:   $errorstring='';
   18:   my $time=time;
   19:   my $addhead=<<END;
   20: <script language="JavaScript">
   21:     if (window.location.pathname!="/res/adm/pages/menu.html") {
   22: 	menu=window.open("","LONCAPAmenu");
   23: 	menu.currentURL=window.location.pathname;
   24:     }
   25: </script>
   26: END
   27:   if ($ENV{'browser.mathml'}) {
   28:       &tth::ttminit();
   29:       return '<?xml version="1.0"?>'
   30:             .'<?xml-stylesheet type="text/css" href="/adm/MathML/mathml.css"?>'
   31:             .'<!DOCTYPE html SYSTEM "/adm/MathML/mathml.dtd" '
   32:             .'[<!ENTITY mathns "http://www.w3.org/1998/Math/MathML">]>'
   33:             .'<html xmlns:math="http://www.w3.org/1998/Math/MathML" ' 
   34:             .'xmlns="http://www.w3.org/TR/REC-html40">'
   35: 	    ."<head>$addhead</head>"
   36:             ."\n";
   37:   } else {
   38:       &tth::tthinit();
   39:       my $headerstring='<html>';
   40:       if ($ENV{'browser.os'} eq 'mac') { 
   41:          $headerstring.="<head>\n"
   42:              .'<meta Content-Type="text/html; charset=x-mac-roman">'
   43: 	     ."\n$addhead</head>\n";
   44:       }
   45:       else {
   46: 	  $headerstring.="<head>$addhead</head>";
   47:       }
   48:       return $headerstring."\n";
   49:   }
   50: }
   51: 
   52: # ================================================================== Conversion
   53: 
   54: sub converted {
   55:     my $texstring=shift;
   56:     my $xmlstring;
   57:     if ($ENV{'browser.mathml'}) {
   58:       $xmlstring=&tth::ttm($$texstring);
   59:       $xmlstring=~s/\<math\>/\<math xmlns=\"\&mathns\;\"\>/g;
   60:       $xmlstring=~s/\<br\>/\<br\/\>/g;
   61:       $xmlstring=~s/\<p\>/\<p\>\<\/p\>/g;
   62:       $errorstring.=&tth::ttmerror();
   63:   } else {
   64:       $xmlstring=&tth::tth($$texstring);
   65:       $errorstring.=&tth::ttherror();
   66:   }
   67:   return $xmlstring;
   68: }
   69: 
   70: # ====================================================================== Footer
   71: 
   72: sub footer {
   73:   my $xmlstring='';
   74:   if ($ENV{'request.state'} eq 'construct') {
   75:       $xmlstring.='<address>'.$errorstring.'</address>';
   76:   } else {
   77:       &Apache::lonmsg::author_res_msg($ENV{'request.filename'},$errorstring);
   78:   }
   79: # -------------------------------------------------------------------- End Body
   80:   $xmlstring.='</html>';
   81:   return $xmlstring;
   82: }
   83: 
   84: 1;
   85: __END__
   86: 
   87: 
   88: 
   89: 
   90: 
   91: 
   92: 

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