version 1.85, 2008/01/29 11:04:10
|
version 1.90, 2008/11/18 10:02:56
|
Line 85 $Apache::lontexconvert::messedup=0;
|
Line 85 $Apache::lontexconvert::messedup=0;
|
# into the safe space since opcode checks only occur at compile time |
# into the safe space since opcode checks only occur at compile time |
sub convert_real { |
sub convert_real { |
my ($texstring)=@_; |
my ($texstring)=@_; |
&Apache::lonnet::logthis("convert_real converting '$$texstring"); |
|
my ($xmlstring,$errorstring); |
my ($xmlstring,$errorstring); |
local $SIG{SEGV}=sub { $Apache::lontexconvert::messedup=1; die; }; |
local $SIG{SEGV}=sub { $Apache::lontexconvert::messedup=1; die; }; |
local $SIG{ALRM}=sub { |
local $SIG{ALRM}=sub { |
Line 96 sub convert_real {
|
Line 95 sub convert_real {
|
}; |
}; |
&Apache::lonxml::start_alarm(); |
&Apache::lonxml::start_alarm(); |
if ($env{'browser.mathml'}) { |
if ($env{'browser.mathml'}) { |
&Apache::lonnet::logthis("mathml translation"); |
|
$xmlstring=&tth::ttm($$texstring); |
$xmlstring=&tth::ttm($$texstring); |
$xmlstring=~s/\<math\>/\<math xmlns=\"\&mathns\;\"\>/g; |
$xmlstring=~s/\<math\>/\<math xmlns=\"\&mathns\;\"\>/g; |
$xmlstring=~s/\<br\>/\<br\/\>/g; |
$xmlstring=~s/\<br\>/\<br\/\>/g; |
$xmlstring=~s/\<p\>/\<p\>\<\/p\>/g; |
$xmlstring=~s/\<p\>/\<p\>\<\/p\>/g; |
$errorstring.=&tth::ttmerror(); |
$errorstring.=&tth::ttmerror(); |
} else { |
} else { |
&Apache::lonnet::logthis("tth translation"); |
|
$xmlstring=&tth::tth($$texstring); |
$xmlstring=&tth::tth($$texstring); |
$errorstring.=&tth::ttherror(); |
$errorstring.=&tth::ttherror(); |
$xmlstring=~s-</font(\s*)>-</font>-g; |
$xmlstring=~s-</font(\s*)>-</font>-g; |
Line 116 sub convert_real {
|
Line 113 sub convert_real {
|
# reasonably well to ⇔. If we get many more of these, |
# reasonably well to ⇔. If we get many more of these, |
# we're going to need to have a translation sub. |
# we're going to need to have a translation sub. |
# |
# |
$xmlstring=~s/\\rightleftharpoons/\&\#8660;/g; |
my $lrharpoon = pack("U", 0x21cc); |
|
$xmlstring=~s/\\rightleftharpoons/$lrharpoon/g; |
|
|
&Apache::lonnet::logthis("Final result: $xmlstring"); |
|
&Apache::lonxml::end_alarm(); |
&Apache::lonxml::end_alarm(); |
return ($xmlstring,$errorstring); |
return ($xmlstring,$errorstring); |
} |
} |
Line 222 sub jsMath_converted {
|
Line 219 sub jsMath_converted {
|
|
|
sub tex_engine { |
sub tex_engine { |
if (exists($env{'form.texengine'})) { |
if (exists($env{'form.texengine'})) { |
return $env{'form.texengine'}; |
if ($env{'form.texengine'} ne '') { |
|
return $env{'form.texengine'}; |
|
} |
} |
} |
if ($env{'request.course.id'} |
if ($env{'request.course.id'} |
&& exists($env{'course.'.$env{'request.course.id'}.'.texengine'})) { |
&& exists($env{'course.'.$env{'request.course.id'}.'.texengine'})) { |
Line 254 sub mimetex_converted {
|
Line 253 sub mimetex_converted {
|
if ($displaystyle) { |
if ($displaystyle) { |
$$texstring='\\displaystyle \\Large '.$$texstring; |
$$texstring='\\displaystyle \\Large '.$$texstring; |
} |
} |
my $result='<img src="/cgi-bin/mimetex.cgi?'.&escape($$texstring).'" />'; |
my $result='<img src="/cgi-bin/mimetex.cgi?'.&escape($$texstring).'" alt="$'.$$texstring.'$" />'; |
if ($displaystyle) { |
if ($displaystyle) { |
$result='<center>'.$result.'</center>'; |
$result='<center>'.$result.'</center>'; |
} |
} |
Line 354 sub msgtexconverted {
|
Line 353 sub msgtexconverted {
|
sub algebra { |
sub algebra { |
use AlgParser; |
use AlgParser; |
|
|
my ($string,$target,$style)=@_; |
my ($string,$target,$style,$parstack,$safeeval)=@_; |
my $parser = new AlgParserWithImplicitExpand; |
my $parser = new AlgParserWithImplicitExpand; |
$string=&prepare_algebra($string); |
$string=&prepare_algebra($string); |
my $ret = $parser->parse($string); |
my $ret = $parser->parse($string); |
Line 371 sub algebra {
|
Line 370 sub algebra {
|
$latex='\\ensuremath{'.$latex.'}'; |
$latex='\\ensuremath{'.$latex.'}'; |
} |
} |
if ($target eq 'web' || $target eq 'analyze') { |
if ($target eq 'web' || $target eq 'analyze') { |
$result = &converted(\$latex); |
my $display=&Apache::lonxml::get_param('display',$parstack,$safeeval); |
|
$result = &converted(\$latex,$display); |
|
# $result = &converted(\$latex); |
} else { |
} else { |
$result = $latex; |
$result = $latex; |
} |
} |