version 1.66, 2005/06/09 02:17:11
|
version 1.73, 2006/05/17 22:08:08
|
Line 42 package Apache::lontexconvert;
|
Line 42 package Apache::lontexconvert;
|
use strict; |
use strict; |
use tth(); |
use tth(); |
use vars qw($errorstring); |
use vars qw($errorstring); |
use Apache(); |
#use Apache::lonxml(); |
use Apache::lonmsg(); |
|
use Apache::lonxml(); |
|
use Apache::lonmenu(); |
|
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonnet; |
use Apache::lonnet; |
|
|
Line 70 sub init_tth {
|
Line 67 sub init_tth {
|
} |
} |
} |
} |
|
|
sub header { |
|
$errorstring=''; |
|
my $time=time; |
|
&init_tth(); |
|
return &Apache::lonxml::xmlbegin(). |
|
"\n<head>\n". |
|
&Apache::lonxml::fontsettings(). |
|
&Apache::lonmenu::registerurl(undef,'tex'). |
|
"\n</head>\n"; |
|
} |
|
|
|
# ================================================================== Conversion |
# ================================================================== Conversion |
|
|
$Apache::lontexconvert::messedup=0; |
$Apache::lontexconvert::messedup=0; |
Line 137 ENDCONV
|
Line 123 ENDCONV
|
$errorstring) { |
$errorstring) { |
&Apache::lonnet::logthis("Trying to kill myself"); |
&Apache::lonnet::logthis("Trying to kill myself"); |
$Apache::lontexconvert::messedup=1; |
$Apache::lontexconvert::messedup=1; |
my $request=Apache->request(); |
if (ref($Apache::lonxml::request)) { |
$request->child_terminate(); |
$Apache::lonxml::request->child_terminate(); |
|
} else { |
|
my $request; |
|
eval { $request=Apache->request; }; |
|
if (!$request) { |
|
eval { $request=Apache2::RequestUtil->request; }; |
|
} |
|
if ($request) { |
|
$request->child_terminate(); |
|
} else { |
|
&Apache::lonnet::logthis("Unable to find a request to do child_terminate on"); |
|
} |
|
} |
} |
} |
return $xmlstring; |
return $xmlstring; |
} |
} |
Line 165 sub jsMath_converted {
|
Line 163 sub jsMath_converted {
|
my $tag='span'; |
my $tag='span'; |
if (&displaystyle($texstring)) { $tag='div'; } |
if (&displaystyle($texstring)) { $tag='div'; } |
&clean_out_math_mode($texstring); |
&clean_out_math_mode($texstring); |
return '<'.$tag.' class="math">'.$$texstring.'</'.$tag.'>'; |
return &jsMath_header(). |
|
'<'.$tag.' class="math">'.$$texstring.'</'.$tag.'>'; |
|
} |
|
|
|
{ |
|
my $jsMath_sent_header; |
|
sub jsMath_reset { |
|
$jsMath_sent_header=0; |
|
} |
|
sub jsMath_header { |
|
return '' if $jsMath_sent_header; |
|
$jsMath_sent_header=1; |
|
return |
|
'<script type="text/javascript"> |
|
function NoFontMessage () {} |
|
</script>'."\n". |
|
'<script type="text/javascript" src="/adm/jsMath/jsMath.js"></script>'."\n"; |
|
} |
|
sub jsMath_process { |
|
return '' if !$jsMath_sent_header; |
|
return '<script type="text/javascript">jsMath.Process()</script>'; |
|
} |
|
} |
|
|
|
sub init_math_support { |
|
&init_tth(); |
|
&Apache::lontexconvert::jsMath_reset(); |
|
if ($env{'environment.texengine'} eq 'jsMath' || |
|
$env{'form.texengine'} eq 'jsMath' ) { |
|
return &Apache::lontexconvert::jsMath_header(); |
|
} |
|
return; |
} |
} |
|
|
sub mimetex_converted { |
sub mimetex_converted { |
Line 185 sub mimetex_converted {
|
Line 214 sub mimetex_converted {
|
} |
} |
|
|
sub converted { |
sub converted { |
if ($env{'environment.texengine'} eq 'tth') { |
my ($string,$mode)=@_; |
return &tth_converted; |
if ($mode eq '') { $mode=$env{'environment.texengine'}; } |
} elsif ($env{'environment.texengine'} eq 'jsMath') { |
if ($mode =~ /tth/i) { |
return &jsMath_converted; |
return &tth_converted($string); |
} elsif ($env{'environment.texengine'} eq 'mimetex') { |
} elsif ($mode =~ /jsmath/i) { |
return &mimetex_converted; |
return &jsMath_converted($string); |
} |
} elsif ($mode =~ /mimetex/i) { |
return &tth_converted; |
return &mimetex_converted($string); |
} |
} |
|
return &tth_converted($string); |
# ====================================================================== Footer |
|
|
|
sub footer { |
|
my $xmlstring=''; |
|
if ($env{'request.state'} eq 'construct') { |
|
$xmlstring.='<address>'.$errorstring.'</address>'; |
|
} else { |
|
&Apache::lonmsg::author_res_msg($env{'request.filename'},$errorstring); |
|
} |
|
# -------------------------------------------------------------------- End Body |
|
$xmlstring.=&Apache::lonxml::xmlend(); |
|
return $xmlstring; |
|
} |
} |
|
|
# ------------------------------------------------------------ Message display |
# ------------------------------------------------------------ Message display |