--- loncom/xml/londefdef.pm 2003/08/26 21:31:19 1.168
+++ loncom/xml/londefdef.pm 2003/10/01 20:45:05 1.177
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Tags Default Definition Module
#
-# $Id: londefdef.pm,v 1.168 2003/08/26 21:31:19 albertel Exp $
+# $Id: londefdef.pm,v 1.177 2003/10/01 20:45:05 albertel Exp $
#
#
# Copyright Michigan State University Board of Trustees
@@ -410,7 +410,7 @@ sub end_meta {
my $content=&Apache::lonxml::get_param('content',$parstack,$safeeval);
my $name=&Apache::lonxml::get_param('name',$parstack,$safeeval);
if ((not defined $content) && (not defined $name)) {
- &Apache::lonxml::startredirection();
+ &Apache::lonxml::endredirection();
}
}
return $currentstring;
@@ -466,6 +466,10 @@ sub start_body {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
if ($target eq 'web') {
+ if ($Apache::lonhomework::parsing_a_problem) {
+ &Apache::lonxml::warning("
tag found inside of tag this can cause problems.");
+ return '';
+ }
if (!$Apache::lonxml::registered) {
$currentstring.=''.
&Apache::lonmenu::registerurl(undef,$target).'';
@@ -537,7 +541,7 @@ sub end_body {
if ($target eq 'web') {
$currentstring = $token->[2];
} elsif ($target eq 'tex') {
- $currentstring = '\end{document}';
+ $currentstring = '\strut\newline\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\newline\noindent \end{document}';
}
return $currentstring;
}
@@ -1634,45 +1638,77 @@ 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;
}
-#-- tag
+#-- tag (end tag optional)
sub start_dt {
- my ($target,$token) = @_;
- my $currentstring = '';
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
+ my $currentstring='';
if ($target eq 'web') {
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
- $currentstring = '\item[';
+ 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;
}
sub end_dt {
- my ($target,$token) = @_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
if ($target eq 'web') {
$currentstring = $token->[2];
} elsif ($target eq 'tex') {
- $currentstring = ']';
+ my $data=&item_cleanup;
+ push @Apache::londefdef::description,'\item['.$data.']';
+ $Apache::londefdef::DT_redirection=0;
}
return $currentstring;
}
+sub item_cleanup {
+ my $item=&Apache::lonxml::endredirection();
+ $item=~s/\\begin{center}//g;
+ $item=~s/\\end{center}//g;
+ return $item;
+}
+
#-- tag
sub start_dd {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
@@ -1680,21 +1716,26 @@ sub start_dd {
if ($target eq 'web') {
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
- if ($$tagstack[-2] eq 'dl') {
- $currentstring = ' \item [] ';
- } elsif ($$tagstack[-2] eq 'dt') {
- $currentstring = ']';
+ if ($Apache::londefdef::DT_redirection) {
+ my $data=&item_cleanup;
+ 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;
}
@@ -2161,7 +2202,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;
}
@@ -2172,7 +2222,6 @@ sub end_applet {
if ($target eq 'web') {
$currentstring = $token->[2];
} elsif ($target eq 'tex') {
- $currentstring = " \\end{figure}";
}
return $currentstring;
}
@@ -2195,7 +2244,6 @@ sub start_embed {
$currentstring='[EMBED: '.$alttag.']';
}
} elsif ($target eq 'tex') {
- $currentstring = " \\begin{figure} ";
}
return $currentstring;
}
@@ -2205,8 +2253,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;
}
@@ -2225,7 +2272,6 @@ sub start_param {
if ($target eq 'web') {
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
- $currentstring = " \\begin{figure} ";
}
return $currentstring;
}
@@ -2236,7 +2282,6 @@ sub end_param {
if ($target eq 'web') {
$currentstring = $token->[2];
} elsif ($target eq 'tex') {
- $currentstring = " \\end{figure}";
}
return $currentstring;
}