--- loncom/xml/lontexconvert.pm 2003/03/13 16:16:07 1.20
+++ loncom/xml/lontexconvert.pm 2003/10/18 15:53:00 1.27
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# TeX Conversion Module
#
-# $Id: lontexconvert.pm,v 1.20 2003/03/13 16:16:07 www Exp $
+# $Id: lontexconvert.pm,v 1.27 2003/10/18 15:53:00 www 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 Unconverted 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,7 +129,8 @@ 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);
}
@@ -135,19 +138,20 @@ sub to_convert {
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 %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/$_/\
/gs;
@@ -174,11 +178,20 @@ 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 &smiley($message).$errorstring;
+ my $outmessage='';
+ my $tex=0;
+ foreach (split(/(?:\<\;|\<)\/*m\s*(?:\>\;|\>)/i,$message)) {
+ if ($tex) {
+ $outmessage.=&to_convert($_); $tex=0;
+ } else {
+ $outmessage.=&smiley($_); $tex=1;
+ }
+ }
+ if (wantarray) {
+ return ($outmessage,$errorstring);
+ } else {
+ return $outmessage.$errorstring;
+ }
}
1;