--- loncom/xml/lontexconvert.pm 2003/02/27 21:01:39 1.19
+++ loncom/xml/lontexconvert.pm 2003/06/23 21:28:59 1.24
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# TeX Conversion Module
#
-# $Id: lontexconvert.pm,v 1.19 2003/02/27 21:01:39 albertel Exp $
+# $Id: lontexconvert.pm,v 1.24 2003/06/23 21:28:59 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -83,7 +83,7 @@ sub converted {
my $texstring=shift;
my $xmlstring='[UNDISPLAYABLE]';
if ($Apache::lontexconvert::messedup) {
- return '[Uncoverted Due To Previous Errors]';
+ return '[TeX Uncoverted Due To Previous Errors]';
}
eval(<<'ENDCONV');
{
@@ -98,6 +98,8 @@ sub converted {
$xmlstring=&tth::tth($$texstring);
$errorstring.=&tth::ttherror();
}
+ $xmlstring=~s/^\s*//;
+ $xmlstring=~s/\s*$//;
}
ENDCONV
if ($Apache::lontexconvert::messedup || &tth::tthmessedup()) {
@@ -127,11 +129,35 @@ sub footer {
sub to_convert {
my ($string) = @_;
- $string=~s/\
/ /g;
+ $string=~s/\
/ /gs;
+ $string=~s/\s/ /gs;
$string=&HTML::Entities::decode($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',
+ ':\-*\(' => 'frowny',
+ '\:\-*(o|O|\(\))' => 'shocked',
+ '\;\-*\)' => 'wink',
+ '\:\-*P' => 'baeh',
+ '\:\-(\\\|\\/)' => 'hrrm',
+ '\:\-*D' => 'bigsmile',
+ '\:\-*C' => 'angry',
+ '\:(\'|\`)\-*\(' => 'cry',
+ '\:\-*(X|\#)' => 'lipsrsealed',
+ '\:\-*S' => 'huh');
+ my $iconpath=$Apache::lonnet::perlvar{'lonIconsURL'};
+ foreach (keys %smileys) {
+ $expression=~s/$_/\/gs;
+ }
+ return $expression;
+}
+
sub msgtexconverted {
my $message=shift;
@@ -151,11 +177,15 @@ sub msgtexconverted {
&tth::tthoptions('-L -u0');
}
}
- $message=~s/(\$\$.+?\$\$)/&to_convert($1)/ge;
- $message=~s/(\$.+?\$)/&to_convert($1)/ge;
- $message=~s/(\\\(.+?\\\))/&to_convert($1)/ge;
- $message=~s/(\\\[.+?\\\])/&to_convert($1)/ge;
- return $message.$errorstring;
+ $message=~s/(\$\$.+?\$\$)/&to_convert($1)/gse;
+ $message=~s/(\$.+?\$)/&to_convert($1)/gse;
+ $message=~s/(\\\(.+?\\\))/&to_convert($1)/gse;
+ $message=~s/(\\\[.+?\\\])/&to_convert($1)/gse;
+ if (wantarray) {
+ return (&smiley($message),$errorstring);
+ } else {
+ return &smiley($message).$errorstring;
+ }
}
1;