--- loncom/xml/lonxml.pm 2003/05/29 18:42:22 1.260 +++ loncom/xml/lonxml.pm 2003/08/06 14:30:01 1.268 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.260 2003/05/29 18:42:22 albertel Exp $ +# $Id: lonxml.pm,v 1.268 2003/08/06 14:30:01 bowersj2 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -70,6 +70,7 @@ use Math::Cephes(); use Math::Random(); use Opcode(); + sub register { my ($space,@taglist) = @_; foreach my $temptag (@taglist) { @@ -95,6 +96,8 @@ use Apache::run(); use Apache::londefdef(); use Apache::scripttag(); use Apache::edit(); +use Apache::inputtags(); +use Apache::outputtags(); use Apache::lonnet(); use Apache::File(); use Apache::loncommon(); @@ -386,7 +389,7 @@ sub fontsettings() { if (($ENV{'browser.os'} eq 'mac') && (!$ENV{'browser.mathml'})) { $headerstring.= ''; - } elsif (!$ENV{'browser.mathml'}) { + } elsif (!$ENV{'browser.mathml'} && $ENV{'browser.unicode'}) { $headerstring.= ''; } @@ -489,6 +492,7 @@ sub latex_special_symbols { $current_token=~s/(>|<)/\$$1\$/g; #more or less if ($current_token=~m/\d%/) {$current_token =~ s/(\d)%/$1\\%/g;} #percent after digit if ($current_token=~m/\s%/) {$current_token =~ s/(\s)%/$1\\%/g;} #persent after space + if ($current_token eq '%.') {$current_token = '\%.';} #persent at the end of statement } return $current_token; } @@ -501,7 +505,7 @@ sub inner_xmlparse { my $dontpop=0; while ( $#$pars > -1 ) { while ($token = $$pars['-1']->get_token) { - if (($token->[0] eq 'T') || ($token->[0] eq 'C') || ($token->[0] eq 'D') ) { + if (($token->[0] eq 'T') || ($token->[0] eq 'C') ) { if ($metamode<1) { my $text=$token->[1]; if ($token->[0] eq 'C' && $target eq 'tex') { @@ -510,8 +514,13 @@ sub inner_xmlparse { } $result.=$text; } + } elsif (($token->[0] eq 'D')) { + if ($metamode<1 && $target eq 'web') { + my $text=$token->[1]; + $result.=$text; + } } elsif ($token->[0] eq 'PI') { - if ($metamode<1) { + if ($metamode<1 && $target eq 'web') { $result=$token->[2]; } } elsif ($token->[0] eq 'S') { @@ -1041,7 +1050,7 @@ sub parstring { my $val=$token->[2]->{$_}; $val =~ s/([\%\@\\\"\'])/\\$1/g; #if ($val =~ m/^[\%\@]/) { $val="\\".$val; } - $temp .= "my \$$_=\"$val\";" + $temp .= "my \$$_=\"$val\";"; } } return $temp; @@ -1134,13 +1143,7 @@ sub inserteditinfo { my ($result,$filecontents)=@_; $filecontents = &HTML::Entities::encode($filecontents); # my $editheader='Edit below
'; - my $xml_help = '
'. - &Apache::loncommon::help_open_topic("Greek_Symbols",'Greek Symbols', - undef,undef,600) - .''. - &Apache::loncommon::help_open_topic("Other_Symbols",'Other Symbols', - undef,undef,600) - .'
'; + my $xml_help = Apache::loncommon::helpLatexCheatsheet(); my $titledisplay=&display_title(); my $buttons=(<WARNING:".join('
',@_)."
\n"; + + if ($ENV{'form.grade_target'} ne 'tex') { + if ($ENV{'request.state'} eq 'construct' || $Apache::lonxml::debug) { + print "WARNING:".join('
',@_)."
\n"; + } } } @@ -1383,7 +1393,7 @@ sub register_insert { my $line = $data[$i]; if ( $line =~ /^\#/ || $line =~ /^\s*\n/) { next; } if ( $line =~ /TABLE/ ) { last; } - my ($tag,$descrip,$color,$function,$show) = split(/,/, $line); + my ($tag,$descrip,$color,$function,$show,$helpfile,$helpdesc) = split(/,/, $line); if ($tag) { $insertlist{"$tagnum.tag"} = $tag; $insertlist{"$tagnum.description"} = $descrip; @@ -1391,6 +1401,8 @@ sub register_insert { $insertlist{"$tagnum.function"} = $function; if (!defined($show)) { $show='yes'; } $insertlist{"$tagnum.show"}= $show; + $insertlist{"$tagnum.helpfile"} = $helpfile; + $insertlist{"$tagnum.helpdesc"} = $helpdesc; $insertlist{"$tag.num"}=$tagnum; $tagnum++; } @@ -1425,11 +1437,26 @@ sub description { return $insertlist{$tagnum.'.description'}; } +# Returns a list containing the help file, and the description +sub helpinfo { + my ($token)=@_; + my $tagnum; + my $tag=$token->[1]; + foreach my $namespace (reverse @Apache::lonxml::namespace) { + my $testtag=$namespace.'::'.$tag; + $tagnum=$insertlist{"$testtag.num"}; + if (defined($tagnum)) { last; } + } + if (!defined ($tagnum)) { $tagnum=$Apache::lonxml::insertlist{"$tag.num"}; } + return ($insertlist{$tagnum.'.helpfile'}, $insertlist{$tagnum.'.helpdesc'}); +} + # ----------------------------------------------------------------- whichuser # returns a list of $symb, $courseid, $domain, $name that is correct for # calls to lonnet functions for this setup. # - looks for form.grade_ parameters sub whichuser { + my ($passedsymb)=@_; my ($symb,$courseid,$domain,$name,$publicuser); if (defined($ENV{'form.grade_symb'})) { my $tmp_courseid=$ENV{'form.grade_courseid'}; @@ -1441,7 +1468,11 @@ sub whichuser { $name=$ENV{'form.grade_username'}; } } else { - $symb=&Apache::lonnet::symbread(); + if (!$passedsymb) { + $symb=&Apache::lonnet::symbread(); + } else { + $symb=$passedsymb; + } $courseid=$ENV{'request.course.id'}; $domain=$ENV{'user.domain'}; $name=$ENV{'user.name'};