version 1.17, 2003/02/25 22:50:11
|
version 1.28, 2003/11/06 15:27:07
|
Line 44 package Apache::lontexconvert;
|
Line 44 package Apache::lontexconvert;
|
use strict; |
use strict; |
use tth; |
use tth; |
use vars qw($errorstring); |
use vars qw($errorstring); |
|
use Apache(); |
use Apache::lonmsg; |
use Apache::lonmsg; |
use Apache::lonxml; |
use Apache::lonxml; |
use Apache::lonmenu; |
use Apache::lonmenu; |
Line 77 sub header {
|
Line 78 sub header {
|
|
|
# ================================================================== Conversion |
# ================================================================== Conversion |
|
|
|
$Apache::lontexconvert::messedup=0; |
sub converted { |
sub converted { |
my $texstring=shift; |
my $texstring=shift; |
my $xmlstring='[UNDISPLAYABLE]'; |
my $xmlstring='[UNDISPLAYABLE]'; |
|
if ($Apache::lontexconvert::messedup) { |
|
return '[TeX Unconverted Due To Previous Errors]'; |
|
} |
eval(<<'ENDCONV'); |
eval(<<'ENDCONV'); |
{ |
{ |
local $SIG{SEGV}=sub { die; }; |
local $SIG{SEGV}=sub { $Apache::lontexconvert::messedup=1; die; }; |
if ($ENV{'browser.mathml'}) { |
if ($ENV{'browser.mathml'}) { |
$xmlstring=&tth::ttm($$texstring); |
$xmlstring=&tth::ttm($$texstring); |
$xmlstring=~s/\<math\>/\<math xmlns=\"\&mathns\;\"\>/g; |
$xmlstring=~s/\<math\>/\<math xmlns=\"\&mathns\;\"\>/g; |
Line 92 sub converted {
|
Line 97 sub converted {
|
} else { |
} else { |
$xmlstring=&tth::tth($$texstring); |
$xmlstring=&tth::tth($$texstring); |
$errorstring.=&tth::ttherror(); |
$errorstring.=&tth::ttherror(); |
|
$xmlstring=~s-</font(\s*)>-</font>-g; |
} |
} |
|
$xmlstring=~s/^\s*//; |
|
$xmlstring=~s/\s*$//; |
} |
} |
ENDCONV |
ENDCONV |
|
if ($Apache::lontexconvert::messedup || &tth::tthmessedup()) { |
|
&Apache::lonnet::logthis("Trying to kill myself"); |
|
$Apache::lontexconvert::messedup=1; |
|
my $request=Apache->request(); |
|
$request->child_terminate(); |
|
} |
return $xmlstring; |
return $xmlstring; |
} |
} |
|
|
Line 116 sub footer {
|
Line 130 sub footer {
|
|
|
sub to_convert { |
sub to_convert { |
my ($string) = @_; |
my ($string) = @_; |
$string=~s/\<br\s*\/?\>/ /g; |
$string=~s/\<br\s*\/?\>/ /gs; |
|
$string=~s/\s/ /gs; |
|
$string=&HTML::Entities::decode($string); |
return &converted(\$string); |
return &converted(\$string); |
} |
} |
|
|
|
sub smiley { |
|
my $expression=shift; |
|
if ($ENV{'browser.imagesuppress'} eq 'on') { return $expression; } |
|
my %smileys=('\:\-\)' => 'smiley', |
|
'8\-\)' => 'coolsmile', |
|
'8\-(I|\|)' => 'coolindiff', |
|
':\-(I|\|)' => 'neutral', |
|
'\:\-(o|O|\(\))' => 'shocked', |
|
':\-\(' => 'frowny', |
|
'\;\-\)' => 'wink', |
|
'\:\-P' => 'baeh', |
|
'\:\-(\\\|\\/)' => 'hrrm', |
|
'\:\-D' => 'bigsmile', |
|
'\:\-C' => 'angry', |
|
'\:(\'|\`)\-\(' => 'cry', |
|
'\:\-(X|\#)' => 'lipsrsealed', |
|
'\:\-S' => 'huh'); |
|
my $iconpath=$Apache::lonnet::perlvar{'lonIconsURL'}; |
|
foreach (keys %smileys) { |
|
$expression=~s/$_/\<img src="$iconpath\/$smileys{$_}.gif" \/\>/gs; |
|
} |
|
return $expression; |
|
} |
|
|
sub msgtexconverted { |
sub msgtexconverted { |
my $message=shift; |
my $message=shift; |
|
|
Line 139 sub msgtexconverted {
|
Line 179 sub msgtexconverted {
|
&tth::tthoptions('-L -u0'); |
&tth::tthoptions('-L -u0'); |
} |
} |
} |
} |
$message=~s/(\$\$.+?\$\$)/&to_convert($1)/ge; |
my $outmessage=''; |
$message=~s/(\$.+?\$)/&to_convert($1)/ge; |
my $tex=0; |
$message=~s/(\\\(.+?\\\))/&to_convert($1)/ge; |
foreach (split(/(?:\<\;|\<)\/*m\s*(?:\>\;|\>)/i,$message)) { |
$message=~s/(\\\[.+?\\\])/&to_convert($1)/ge; |
if ($tex) { |
return $message.$errorstring; |
$outmessage.=&to_convert($_); $tex=0; |
|
} else { |
|
$outmessage.=&smiley($_); $tex=1; |
|
} |
|
} |
|
if (wantarray) { |
|
return ($outmessage,$errorstring); |
|
} else { |
|
return $outmessage.$errorstring; |
|
} |
} |
} |
|
|
1; |
1; |