--- loncom/xml/londefdef.pm 2003/09/25 16:09:14 1.173
+++ loncom/xml/londefdef.pm 2003/10/14 00:21:12 1.180
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Tags Default Definition Module
#
-# $Id: londefdef.pm,v 1.173 2003/09/25 16:09:14 sakharuk Exp $
+# $Id: londefdef.pm,v 1.180 2003/10/14 00:21:12 albertel Exp $
#
#
# Copyright Michigan State University Board of Trustees
@@ -92,9 +92,15 @@ sub start_m {
$Apache::lontexconvert::errorstring='';
}
#&Apache::lonxml::debug("M is ends with:$currentstring:");
+ $Apache::lonxml::post_evaluate=0;
} elsif ($target eq 'tex') {
$currentstring = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
+ my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval);
+ if ($eval eq 'on') {
+ $currentstring=&Apache::run::evaluate($currentstring,$safeeval,$$parstack[-1]);
+ }
if ($currentstring=~/^(\s*\\\\\s*)*$/) {$currentstring = ' \vskip 0 mm ';}
+ $Apache::lonxml::post_evaluate=0;
} else {
my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
}
@@ -195,7 +201,7 @@ sub start_head {
sub end_head {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' && $ENV{'request.state'} eq 'published') {
$currentstring = &Apache::lonmenu::registerurl(undef,$target).
$token->[2];
}
@@ -470,7 +476,8 @@ sub start_body {
&Apache::lonxml::warning("
tag found inside of tag this can cause problems.");
return '';
}
- if (!$Apache::lonxml::registered) {
+ if (!$Apache::lonxml::registered &&
+ $ENV{'request.state'} eq 'published') {
$currentstring.=''.
&Apache::lonmenu::registerurl(undef,$target).'';
}
@@ -887,7 +894,7 @@ sub start_cite {
if ($target eq 'web') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
- $currentstring .= "\\textit{";
+ $currentstring .= '\textit{';
}
return $currentstring;
}
@@ -898,7 +905,7 @@ sub end_cite {
if ($target eq 'web') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
- $currentstring .= "}";
+ $currentstring .= '}';
}
return $currentstring;
}
@@ -933,7 +940,7 @@ sub start_address {
if ($target eq 'web') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
- $currentstring .= "\\textit{";
+ $currentstring .= '\textit{';
}
return $currentstring;
}
@@ -944,7 +951,7 @@ sub end_address {
if ($target eq 'web') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
- $currentstring .= "}";
+ $currentstring .= '}';
}
return $currentstring;
}
@@ -956,7 +963,7 @@ sub start_dfn {
if ($target eq 'web') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
- $currentstring .= "\\textit{";
+ $currentstring .= '\textit{';
}
return $currentstring;
}
@@ -967,7 +974,7 @@ sub end_dfn {
if ($target eq 'web') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
- $currentstring .= "}";
+ $currentstring .= '}';
}
return $currentstring;
}
@@ -1002,7 +1009,7 @@ sub start_kbd {
if ($target eq 'web') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
- $currentstring .= "\\texttt";
+ $currentstring .= '\texttt{';
}
return $currentstring;
}
@@ -1013,7 +1020,7 @@ sub end_kbd {
if ($target eq 'web') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
- $currentstring .= "}";
+ $currentstring .= '}';
}
return $currentstring;
}
@@ -1071,7 +1078,7 @@ sub start_q {
if ($target eq 'web') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
- $currentstring .= "\\emph{";
+ $currentstring .= '\emph{';
}
return $currentstring;
}
@@ -1082,7 +1089,7 @@ sub end_q {
if ($target eq 'web') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
- $currentstring .= "}";
+ $currentstring .= '}';
}
return $currentstring;
}
@@ -1638,18 +1645,32 @@ sub start_dl {
if ($target eq 'web') {
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
- $currentstring = '\begin{description}';
+ $currentstring = '\begin{description}';
+ @Apache::londefdef::description=();
+ $Apache::londefdef::DD_redirection=0;
+ $Apache::londefdef::DT_redirection=0;
}
return $currentstring;
}
sub end_dl {
- my ($target,$token) = @_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
if ($target eq 'web') {
$currentstring = $token->[2];
} elsif ($target eq 'tex') {
- $currentstring = '\end{description}';
+ if ($Apache::londefdef::DT_redirection) {
+ my $data=&item_cleanup;
+ push @Apache::londefdef::description,'\item['.$data.']';
+ $Apache::londefdef::DT_redirection=0;
+ } elsif ($Apache::londefdef::DD_redirection) {
+ $Apache::londefdef::description[-1].=&Apache::lonxml::endredirection();
+ }
+ foreach my $element (@Apache::londefdef::description) {
+ $currentstring.=' '.$element.' ';
+ }
+ @Apache::londefdef::description=();
+ $currentstring.='\end{description}';
}
return $currentstring;
}
@@ -1661,7 +1682,16 @@ sub start_dt {
if ($target eq 'web') {
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
- &Apache::lonxml::startredirection();;
+ if ($Apache::londefdef::DT_redirection) {
+ my $data=&item_cleanup;
+ push @Apache::londefdef::description,'\item['.$data.']';
+ $Apache::londefdef::DT_redirection=0;
+ } elsif ($Apache::londefdef::DD_redirection) {
+ $Apache::londefdef::description[-1].=&Apache::lonxml::endredirection();
+ $Apache::londefdef::DD_redirection=0;
+ }
+ &Apache::lonxml::startredirection();
+ $Apache::londefdef::DT_redirection=1;
}
return $currentstring;
}
@@ -1673,13 +1703,14 @@ sub end_dt {
$currentstring = $token->[2];
} elsif ($target eq 'tex') {
my $data=&item_cleanup;
- $currentstring.='\item['.$data.']';
+ push @Apache::londefdef::description,'\item['.$data.']';
+ $Apache::londefdef::DT_redirection=0;
}
return $currentstring;
}
sub item_cleanup {
- my $item=&Apache::lonxml::endredirection();;
+ my $item=&Apache::lonxml::endredirection();
$item=~s/\\begin{center}//g;
$item=~s/\\end{center}//g;
return $item;
@@ -1692,20 +1723,26 @@ sub start_dd {
if ($target eq 'web') {
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
- if ($$tagstack[-2] eq 'dt') {
+ if ($Apache::londefdef::DT_redirection) {
my $data=&item_cleanup;
- $currentstring.='\item['.$data.']';
+ push @Apache::londefdef::description,'\item['.$data.']';
+ $Apache::londefdef::DT_redirection=0;
}
+ $Apache::londefdef::DD_redirection=1;
+ &Apache::lonxml::startredirection();
}
return $currentstring;
}
sub end_dd {
- my ($target,$token) = @_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
if ($target eq 'web') {
$currentstring = $token->[2];
- }
+ } elsif ($target eq 'tex') {
+ $Apache::londefdef::description[-1].=&Apache::lonxml::endredirection();
+ $Apache::londefdef::DD_redirection=0;
+ }
return $currentstring;
}
@@ -2172,7 +2209,16 @@ sub start_applet {
$currentstring='[APPLET: '.$alttag.']';
}
} elsif ($target eq 'tex') {
- $currentstring = " \\begin{figure} ";
+ my $alttag= &Apache::lonxml::get_param('alt',$parstack,
+ $safeeval,undef,1);
+ unless ($alttag) {
+ my $code=&Apache::lonxml::get_param('code',$parstack,$safeeval,
+ undef,1);
+ $alttag=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],
+ $code);
+ }
+ $currentstring.='\begin{center} \fbox{Java Applet: '.$alttag.
+ '.}\end{center}';
}
return $currentstring;
}
@@ -2183,7 +2229,6 @@ sub end_applet {
if ($target eq 'web') {
$currentstring = $token->[2];
} elsif ($target eq 'tex') {
- $currentstring = " \\end{figure}";
}
return $currentstring;
}
@@ -2206,7 +2251,6 @@ sub start_embed {
$currentstring='[EMBED: '.$alttag.']';
}
} elsif ($target eq 'tex') {
- $currentstring = " \\begin{figure} ";
}
return $currentstring;
}
@@ -2216,8 +2260,7 @@ sub end_embed {
my $currentstring = '';
if ($target eq 'web') {
$currentstring = $token->[2];
- } elsif ($target eq 'tex') {
- $currentstring = " \\end{figure}";
+ } elsif ($target eq 'tex') {
}
return $currentstring;
}
@@ -2236,7 +2279,6 @@ sub start_param {
if ($target eq 'web') {
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
- $currentstring = " \\begin{figure} ";
}
return $currentstring;
}
@@ -2247,7 +2289,6 @@ sub end_param {
if ($target eq 'web') {
$currentstring = $token->[2];
} elsif ($target eq 'tex') {
- $currentstring = " \\end{figure}";
}
return $currentstring;
}
@@ -2284,7 +2325,8 @@ sub start_frameset {
my ($target,$token) = @_;
my $currentstring = '';
if ($target eq 'web') {
- if (!$Apache::lonxml::registered) {
+ if (!$Apache::lonxml::registered &&
+ $ENV{'request.state'} eq 'published') {
$currentstring.=''.
&Apache::lonmenu::registerurl(undef,$target).'';
}
@@ -2886,8 +2928,8 @@ sub end_marquee {
return $currentstring;
}
-#-- tag
-sub start_malticol {
+#-- tag (end tag required)
+sub start_multicol {
my ($target,$token) = @_;
my $currentstring = '';
if ($target eq 'web') {
@@ -2896,7 +2938,7 @@ sub start_malticol {
return $currentstring;
}
-sub end_malticol {
+sub end_multicol {
my ($target,$token) = @_;
my $currentstring = '';
if ($target eq 'web') {
@@ -2905,13 +2947,15 @@ sub end_malticol {
return $currentstring;
}
-#-- tag
+#-- tag (end tag required)
sub start_nobr {
my ($target,$token) = @_;
my $currentstring = '';
if ($target eq 'web') {
$currentstring = $token->[4];
- }
+ } elsif ($target eq 'tex') {
+ $currentstring='\mbox{';
+ }
return $currentstring;
}
@@ -2920,11 +2964,13 @@ sub end_nobr {
my $currentstring = '';
if ($target eq 'web') {
$currentstring = $token->[2];
- }
+ } elsif ($target eq 'tex') {
+ $currentstring='}';
+ }
return $currentstring;
}
-#-- tag
+#-- tag (end tag required)
sub start_noembed {
my ($target,$token) = @_;
my $currentstring = '';
@@ -2943,7 +2989,7 @@ sub end_noembed {
return $currentstring;
}
-#-- tag
+#-- tag (end tag required)
sub start_noframes {
my ($target,$token) = @_;
my $currentstring = '';
@@ -2962,7 +3008,7 @@ sub end_noframes {
return $currentstring;
}
-#-- tag
+#-- tag (end tag required)
sub start_nolayer {
my ($target,$token) = @_;
my $currentstring = '';
@@ -2981,7 +3027,7 @@ sub end_nolayer {
return $currentstring;
}
-#--