version 1.23, 2003/06/09 21:37:54
|
version 1.30, 2004/01/28 20:48:35
|
Line 51 use Apache::lonmenu;
|
Line 51 use Apache::lonmenu;
|
|
|
# ====================================================================== Header |
# ====================================================================== Header |
|
|
|
sub init_tth { |
|
my $options=$ENV{'course.'.$ENV{'request.course.id'}.'.tthoptions'}; |
|
if ($ENV{'browser.mathml'}) { |
|
&tth::ttminit(); |
|
if ($ENV{'browser.unicode'}) { |
|
&tth::ttmoptions('-L -u1 '.$options); |
|
} else { |
|
&tth::ttmoptions('-L -u0 '.$options); |
|
} |
|
} else { |
|
&tth::tthinit(); |
|
if ($ENV{'browser.unicode'}) { |
|
&tth::tthoptions('-L -u1 '.$options); |
|
} else { |
|
&tth::tthoptions('-L -u0 '.$options); |
|
} |
|
} |
|
} |
|
|
sub header { |
sub header { |
$errorstring=''; |
$errorstring=''; |
my $time=time; |
my $time=time; |
if ($ENV{'browser.mathml'}) { |
&init_tth(); |
&tth::ttminit(); |
|
if ($ENV{'browser.unicode'}) { |
|
&tth::ttmoptions('-L -u1'); |
|
} else { |
|
&tth::ttmoptions('-L -u0'); |
|
} |
|
} else { |
|
&tth::tthinit(); |
|
if ($ENV{'browser.unicode'}) { |
|
&tth::tthoptions('-L -u1'); |
|
} else { |
|
&tth::tthoptions('-L -u0'); |
|
} |
|
} |
|
return &Apache::lonxml::xmlbegin(). |
return &Apache::lonxml::xmlbegin(). |
&Apache::lonxml::fontsettings(). |
&Apache::lonxml::fontsettings(). |
"\n<head>\n". |
"\n<head>\n". |
Line 83 sub converted {
|
Line 88 sub converted {
|
my $texstring=shift; |
my $texstring=shift; |
my $xmlstring='[UNDISPLAYABLE]'; |
my $xmlstring='[UNDISPLAYABLE]'; |
if ($Apache::lontexconvert::messedup) { |
if ($Apache::lontexconvert::messedup) { |
return '[Uncoverted Due To Previous Errors]'; |
return '[TeX Unconverted Due To Previous Errors]'; |
} |
} |
eval(<<'ENDCONV'); |
eval(<<'ENDCONV'); |
{ |
{ |
Line 97 sub converted {
|
Line 102 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*//; |
$xmlstring=~s/\s*$//; |
$xmlstring=~s/\s*$//; |
Line 130 sub footer {
|
Line 136 sub footer {
|
sub to_convert { |
sub to_convert { |
my ($string) = @_; |
my ($string) = @_; |
$string=~s/\<br\s*\/?\>/ /gs; |
$string=~s/\<br\s*\/?\>/ /gs; |
$string=~s/\s/ /gs; |
# $string=~s/\s/ /gs; |
$string=&HTML::Entities::decode($string); |
$string=&HTML::Entities::decode($string); |
return &converted(\$string); |
return &converted(\$string); |
} |
} |
Line 138 sub to_convert {
|
Line 144 sub to_convert {
|
sub smiley { |
sub smiley { |
my $expression=shift; |
my $expression=shift; |
if ($ENV{'browser.imagesuppress'} eq 'on') { return $expression; } |
if ($ENV{'browser.imagesuppress'} eq 'on') { return $expression; } |
my %smileys=('\:\-*\)' => 'smiley', |
my %smileys=('\:\-\)' => 'smiley', |
'8\-*\)' => 'coolsmile', |
'8\-\)' => 'coolsmile', |
'8\-*I' => 'coolindiff', |
'8\-(I|\|)' => 'coolindiff', |
':\-*\(' => 'frowny', |
':\-(I|\|)' => 'neutral', |
'\:\-*(o|O|\(\))' => 'shocked', |
'\:\-(o|O|\(\))' => 'shocked', |
'\;\-*\)' => 'wink', |
':\-\(' => 'frowny', |
'\:\-*P' => 'baeh', |
'\;\-\)' => 'wink', |
|
'\:\-P' => 'baeh', |
'\:\-(\\\|\\/)' => 'hrrm', |
'\:\-(\\\|\\/)' => 'hrrm', |
'\:\-*D' => 'bigsmile', |
'\:\-D' => 'bigsmile', |
'\:\-*C' => 'angry', |
'\:\-C' => 'angry', |
'\:(\'|\`)\-*\(' => 'cry', |
'\:(\'|\`)\-\(' => 'cry', |
'\:\-*(X|\#)' => 'lipsrsealed', |
'\:\-(X|\#)' => 'lipsrsealed', |
'\:\-*S' => 'huh'); |
'\:\-S' => 'huh'); |
my $iconpath=$Apache::lonnet::perlvar{'lonIconsURL'}; |
my $iconpath=$Apache::lonnet::perlvar{'lonIconsURL'}; |
foreach (keys %smileys) { |
foreach (keys %smileys) { |
$expression=~s/$_/\<img src="$iconpath\/$smileys{$_}.gif" \/\>/gs; |
$expression=~s/$_/\<img src="$iconpath\/$smileys{$_}.gif" \/\>/gs; |
Line 160 sub smiley {
|
Line 167 sub smiley {
|
|
|
sub msgtexconverted { |
sub msgtexconverted { |
my $message=shift; |
my $message=shift; |
|
my $email=shift; |
$errorstring=''; |
$errorstring=''; |
if ($ENV{'browser.mathml'}) { |
&init_tth(); |
&tth::ttminit(); |
my $outmessage=''; |
if ($ENV{'browser.unicode'}) { |
my $tex=0; |
&tth::ttmoptions('-L -u1'); |
foreach (split(/(?:\<\;|\<)\/*m\s*(?:\>\;|\>)/i,$message)) { |
|
if ($tex) { |
|
if ($email) { |
|
$outmessage.='</pre><tt>'.&to_convert($_).'</tt><pre>'; $tex=0; |
|
} else { |
|
$outmessage.=&to_convert($_); $tex=0; |
|
} |
} else { |
} else { |
&tth::ttmoptions('-L -u0'); |
$outmessage.=&smiley($_); $tex=1; |
} |
} |
|
} |
|
if (wantarray) { |
|
return ($outmessage,$errorstring); |
} else { |
} else { |
&tth::tthinit(); |
return $outmessage.$errorstring; |
if ($ENV{'browser.unicode'}) { |
|
&tth::tthoptions('-L -u1'); |
|
} else { |
|
&tth::tthoptions('-L -u0'); |
|
} |
|
} |
} |
$message=~s/(\$\$.+?\$\$)/&to_convert($1)/gse; |
|
$message=~s/(\$.+?\$)/&to_convert($1)/gse; |
|
$message=~s/(\\\(.+?\\\))/&to_convert($1)/gse; |
|
$message=~s/(\\\[.+?\\\])/&to_convert($1)/gse; |
|
return &smiley($message).$errorstring; |
|
} |
} |
|
|
1; |
1; |