--- loncom/xml/londefdef.pm 2004/09/02 18:04:49 1.240
+++ loncom/xml/londefdef.pm 2004/11/13 19:11:34 1.245
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Tags Default Definition Module
#
-# $Id: londefdef.pm,v 1.240 2004/09/02 18:04:49 albertel Exp $
+# $Id: londefdef.pm,v 1.245 2004/11/13 19:11:34 albertel Exp $
#
#
# Copyright Michigan State University Board of Trustees
@@ -63,9 +63,10 @@ sub initialize_londefdef {
$Apache::londefdef::TD_redirection=0;
@Apache::londefdef::table = ();
$Apache::londefdef::select=0;
- @Apache::londefdef::description=();
- $Apache::londefdef::DD_redirection=0;
- $Apache::londefdef::DT_redirection=0;
+ undef(@Apache::londefdef::description);
+ @Apache::londefdef::DD=(0);
+ @Apache::londefdef::DT=(0);
+ @Apache::londefdef::seenDT=(0);
$Apache::londefdef::list_index=0;
}
@@ -151,8 +152,7 @@ sub start_html {
my $options=$ENV{'course.'.$ENV{'request.course.id'}.'.tthoptions'};
&Apache::lontexconvert::init_tth();
if ($target eq 'web' || $target eq 'edit') {
- $currentstring = &Apache::lonxml::xmlbegin().
- &Apache::lonxml::fontsettings();
+ $currentstring = &Apache::lonxml::xmlbegin();
} elsif ($target eq 'tex') {
@Apache::londefdef::table = ();
$currentstring .= '\documentclass[letterpaper]{book}';
@@ -190,7 +190,7 @@ sub start_head {
my ($target,$token) = @_;
my $currentstring = '';
if ($target eq 'web') {
- $currentstring = $token->[4];
+ $currentstring = $token->[4].&Apache::lonxml::fontsettings();
}
return $currentstring;
}
@@ -479,6 +479,7 @@ sub end_accessrule {
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.");
@@ -1698,9 +1699,11 @@ sub start_dl {
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
$currentstring = '\begin{description}';
- @Apache::londefdef::description=();
- $Apache::londefdef::DD_redirection=0;
- $Apache::londefdef::DT_redirection=0;
+ $Apache::londefdef::DL++;
+ push(@Apache::londefdef::description,[]);
+ $Apache::londefdef::DD[$Apache::londefdef::DL]=0;
+ $Apache::londefdef::DT[$Apache::londefdef::DL]=0;
+ $Apache::londefdef::seenDT[$Apache::londefdef::DL]=0;
}
return $currentstring;
}
@@ -1711,18 +1714,17 @@ sub end_dl {
if ($target eq 'web') {
$currentstring = $token->[2];
} elsif ($target eq 'tex') {
- 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) {
+ if ($Apache::londefdef::DT[-1]) { &end_dt(@_); }
+ if ($Apache::londefdef::DD[-1]) { &end_dd(@_); }
+ foreach my $element (@{$Apache::londefdef::description[-1]}) {
$currentstring.=' '.$element.' ';
}
- @Apache::londefdef::description=();
+ pop(@Apache::londefdef::description);
$currentstring.='\end{description}';
+ delete($Apache::londefdef::DD[$Apache::londefdef::DL]);
+ delete($Apache::londefdef::DT[$Apache::londefdef::DL]);
+ delete($Apache::londefdef::seenDT[$Apache::londefdef::DL]);
+ $Apache::londefdef::DL--;
}
return $currentstring;
}
@@ -1734,16 +1736,11 @@ sub start_dt {
if ($target eq 'web') {
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
- 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;
- }
+ if ($Apache::londefdef::DT[-1]) { &end_dt(@_); }
+ if ($Apache::londefdef::DD[-1]) { &end_dd(@_); }
&Apache::lonxml::startredirection();
- $Apache::londefdef::DT_redirection=1;
+ $Apache::londefdef::DT[-1]++;
+ $Apache::londefdef::seenDT[-1]=1;
}
return $currentstring;
}
@@ -1754,9 +1751,11 @@ sub end_dt {
if ($target eq 'web') {
$currentstring = $token->[2];
} elsif ($target eq 'tex') {
- my $data=&item_cleanup;
- push @Apache::londefdef::description,'\item['.$data.']';
- $Apache::londefdef::DT_redirection=0;
+ if ($Apache::londefdef::DT[-1]) {
+ my $data=&item_cleanup();
+ push(@{$Apache::londefdef::description[-1]},'\item['.$data.'] \strut \vskip 0mm');
+ $Apache::londefdef::DT[-1]--;
+ }
}
return $currentstring;
}
@@ -1775,12 +1774,14 @@ sub start_dd {
if ($target eq 'web') {
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
- 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;
+ if ($Apache::londefdef::DT[-1]) { &end_dt(@_); }
+ if ($Apache::londefdef::DD[-1]) { &end_dd(@_);}
+ if (!$Apache::londefdef::seenDT[-1]) {
+ push(@{$Apache::londefdef::description[-1]},'\item[\strut] \strut \vskip 0mm ');
+ }
+ push(@{$Apache::londefdef::description[-1]},'');
+ $Apache::londefdef::description[-1]->[-1].=' \strut ';
+ $Apache::londefdef::DD[-1]++;
&Apache::lonxml::startredirection();
}
return $currentstring;
@@ -1792,8 +1793,9 @@ sub end_dd {
if ($target eq 'web') {
$currentstring = $token->[2];
} elsif ($target eq 'tex') {
- $Apache::londefdef::description[-1].=&Apache::lonxml::endredirection();
- $Apache::londefdef::DD_redirection=0;
+ $Apache::londefdef::description[-1]->[-1].=
+ &Apache::lonxml::endredirection().' \vskip 0mm ';
+ $Apache::londefdef::DD[-1]--;
}
return $currentstring;
}
@@ -2450,7 +2452,7 @@ sub start_img {
if (-e $newsrc) {
#eps counterpart for image exist
if ($path) {
- $currentstring .= '\vskip 1 mm \noindent\graphicspath{{'.$path.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
+ $currentstring .= '\graphicspath{{'.$path.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
}
} else {
#there is no eps counterpart for image - check for ps one
@@ -2459,11 +2461,11 @@ sub start_img {
#ps counterpart for image exist
$file =~ s/\.eps$/\.ps/;
if ($path) {
- $currentstring .= '\vskip 1 mm \noindent\graphicspath{{'.$path.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
+ $currentstring .= '\graphicspath{{'.$path.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
}
} else {
#care about eps dynamical generation
- $currentstring.='\vskip 1 mm '.&eps_generation($src,$file,$width_param);
+ $currentstring.=&eps_generation($src,$file,$width_param);
}
}
} else {
@@ -2672,7 +2674,7 @@ sub start_allow {
$src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
$Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
&Apache::lonnet::clutter($src);
- &image_replication($src);
+ if ($target eq 'tex') { &image_replication($src); }
my $result;
if ($target eq 'edit') {
$result .=&Apache::edit::tag_start($target,$token);