[LON-CAPA-cvs] cvs: modules /gerd translate.pl
www
lon-capa-cvs@mail.lon-capa.org
Wed, 14 Feb 2007 15:32:34 -0000
www Wed Feb 14 10:32:34 2007 EDT
Modified files:
/modules/gerd translate.pl
Log:
New and improved
Index: modules/gerd/translate.pl
diff -u modules/gerd/translate.pl:1.1 modules/gerd/translate.pl:1.2
--- modules/gerd/translate.pl:1.1 Sun Feb 11 15:43:51 2007
+++ modules/gerd/translate.pl Wed Feb 14 10:32:34 2007
@@ -31,6 +31,7 @@
$intermediate.='<td>';
} elsif ($token->[1] eq 'equation') {
$buffer=$intermediate;
+ $intermediate='';
} elsif ($token->[1]=~/^choice\-/) {
$intermediate='';
} else {
@@ -43,7 +44,7 @@
if ($token->[0] eq 'E') {
if ($token->[1] eq 'text') {
$text=$intermediate;
- $text=~s/[^\w\.\;\:\?\!\(\)\<\>\=\"\'\+\-\*\/\n ]//gsi;
+ $text=~s/[^\w\.\;\:\,\\\&\$\?\!\(\)\<\>\=\"\'\+\-\*\/\n ]//gsi;
} elsif ($token->[1]=~/^choice\-(\w+)$/) {
$foils{$1}=$intermediate;
} elsif ($token->[1] eq 'answer') {
@@ -53,7 +54,14 @@
} elsif ($token->[1] eq 'cell') {
$intermediate.='</td>';
} elsif ($token->[1] eq 'equation') {
- $intermediate=$buffer.'<m>$\Sigma$</m>';
+ my $symbols='';
+ foreach my $entity ($intermediate=~/(\&\#[^\;]+\;)/) {
+ if ($entity eq 'μ') { $symbols.='<m>$\mu$</m>'; }
+ if ($entity eq 'σ') { $symbols.='<m>$\sigma$</m>'; }
+ if ($entity eq 'Σ') { $symbols.='<m>$\Sigma$</m>'; }
+ }
+ unless ($symbols) { $symbols='-'; }
+ $intermediate=$buffer.$symbols;
} elsif ($token->[1] eq 'question') {
if ($narrative) {
$text=$allnarratives{$narrative}.'<br />'.$text;
@@ -86,7 +94,7 @@
$output.="\n</foil>";
} else {
foreach my $index ('a'..'z') {
- if ($foils{$index}) {
+ if ($foils{$index}=~/[\w\d]/) {
$output.="\n".'<foil location="'.(($foils{$index}=~/^\s*(none|cannot)/i)?'bottom':'random').'" value="'.((lc($truth) eq lc($index))?'true':'false').'" name="foil'.$index.'">';
$output.="\n<startouttext />$foils{$index}<endouttext />";
$output.="\n</foil>";