Diff for /loncom/xml/londefdef.pm between versions 1.318 and 1.320

version 1.318, 2006/02/04 22:11:42 version 1.320, 2006/02/15 11:57:44
Line 2039  sub end_table { Line 2039  sub end_table {
  my $inmemory = '';   my $inmemory = '';
  my $output = '';   my $output = '';
  my $WARNING='';   my $WARNING='';
  # &debug_dump_table($Apache::londefdef::table[-1]);   &debug_dump_table($Apache::londefdef::table[-1]);
         #width of columns from TeXwidth attributes          #width of columns from TeXwidth attributes
   
  for (my $in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {   for (my $in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
Line 2226  sub end_table { Line 2226  sub end_table {
  for (my $in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {   for (my $in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
     my $have_rowspan = 0;      my $have_rowspan = 0;
     for (my $jn=0;$jn<=$#fwidth;$jn++) {      for (my $jn=0;$jn<=$#fwidth;$jn++) {
   
    #-----------------------------------------------------------
                   #   I think this order of doing things will ensure that
    #   single rowspan, columspan and combined row/colspans will
                   #   work correctly.  LaTeX is delicate here.
    #    RF.
   
    # Start a rowspan if necessary:
   
    my $rowspan = $Apache::londefdef::table[-1]{'rowspan'}[$in][$jn];
    my $colspan = $Apache::londefdef::table[-1]{'colspan'}[$in][$jn];
  #   #
  #  Do the appropriate magic if this has a colspan   #  Do the appropriate magic if this has a colspan
  #    # 
  my $colspan = $Apache::londefdef::table[-1]{'colspan'}[$in][$jn];  
  if ($colspan > 1) {   if ($colspan > 1) {
     $output .= '\multicolumn{'.      $output .= '\multicolumn{'.
  $colspan   $colspan
  .'}{|l|}{';   .'}{|l|}{';
  }   }
  my $rowspan = $Apache::londefdef::table[-1]{'rowspan'}[$in][$jn];  
   
  # Start a rowspan if necessary:  
   
  if ($rowspan > 1) {   if ($rowspan > 1) {
     $have_rowspan++;      $have_rowspan++;
Line 2246  sub end_table { Line 2254  sub end_table {
  if (($rowspan eq '^') || ($rowspan eq '_')) {   if (($rowspan eq '^') || ($rowspan eq '_')) {
     $have_rowspan++;      $have_rowspan++;
  }   }
    #--------------------------------------------------------------
   
  if ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'c') {   if ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'c') {
     $output.=&center_correction().'\begin{center}';      $output.=&center_correction().'\begin{center}';
Line 2280  sub end_table { Line 2289  sub end_table {
  $output .= ' \\\\ ';   $output .= ' \\\\ ';
  for (my $jn=0; $jn<=$#fwidth;$jn++) {   for (my $jn=0; $jn<=$#fwidth;$jn++) {
     my $rowspan = $Apache::londefdef::table[-1]{'rowspan'}[$in][$jn];      my $rowspan = $Apache::londefdef::table[-1]{'rowspan'}[$in][$jn];
     if (($rowspan <= 1) || ($rowspan eq '_')) {      if ($rowspan ne "^") {
  my $column = $jn+1;   if (($rowspan <= 1) || ($rowspan eq '_')) {
  $output .= '\cline{'.$column.'-'.$column.'} ';      my $column = $jn+1;
       $output .= '\cline{'.$column.'-'.$column.'} ';
    }
     }      }
  }   }
   
Line 2452  sub end_td_tex { Line 2463  sub end_td_tex {
     $Apache::londefdef::table[-1]{'counter_columns'} = $current_column;      $Apache::londefdef::table[-1]{'counter_columns'} = $current_column;
         
   
       # Get the column and row spans.
       # Colspan can be done via \multicolumn if I can figure out the data structs.
   
       my $colspan = &Apache::lonxml::get_param('colspan', $parstack, $safeeval, undef, 0);
       if (!$colspan) {
    $colspan = 1;
       }
   
     my $rowspan = &Apache::lonxml::get_param('rowspan', $parstack, $safeeval, undef, 0);      my $rowspan = &Apache::lonxml::get_param('rowspan', $parstack, $safeeval, undef, 0);
     if (!$rowspan) {      if (!$rowspan) {
Line 2460  sub end_td_tex { Line 2478  sub end_td_tex {
   
   
   
     $Apache::londefdef::table[-1]{'rowspan'}[$current_row][$current_column] = $rowspan;      for (my $c = 0; $c < $colspan; $c++) {
     for (my $i = 1; $i < $rowspan; $i++) {   $Apache::londefdef::table[-1]{'rowspan'}[$current_row][$current_column+$c] = $rowspan;
  $Apache::londefdef::table[-1]{'rowspan'}[$current_row+$i][$current_column] = '^';   for (my $i = 1; $i < $rowspan; $i++) {
  if ($i == ($rowspan-1)) {      $Apache::londefdef::table[-1]{'rowspan'}[$current_row+$i][$current_column+$c] = '^';
     $Apache::londefdef::table[-1]{'rowspan'}[$current_row+$i][$current_column] = '_';      if ($i == ($rowspan-1)) {
    $Apache::londefdef::table[-1]{'rowspan'}[$current_row+$i][$current_column+$c] = '_';
       }
  }   }
     }      }
   
Line 2559  sub end_td_tex { Line 2579  sub end_td_tex {
   
     push @ {$Apache::londefdef::table[-1]{'content'}[-1] },$data;      push @ {$Apache::londefdef::table[-1]{'content'}[-1] },$data;
   
     # Get the column and row spans.  
     # Colspan can be done via \multicolumn if I can figure out the data structs.  
   
     my $colspan = &Apache::lonxml::get_param('colspan', $parstack, $safeeval, undef, 0);  
     if (!$colspan) {  
  $colspan = 1;  
     }  
   
   
     #  the colspan array will indicate how many columns will be spanned by this      #  the colspan array will indicate how many columns will be spanned by this
Line 2574  sub end_td_tex { Line 2588  sub end_td_tex {
     #  counter_columns is incremented in the start_td_tex, we adjust by colspan-1.      #  counter_columns is incremented in the start_td_tex, we adjust by colspan-1.
     #      #
   
     $Apache::londefdef::table[-1]{'colspan'}[$current_row][$current_column] = $colspan;  
     $Apache::londefdef::table[-1]{'counter_columns'} += $colspan -1;      $Apache::londefdef::table[-1]{'counter_columns'} += $colspan -1;
   
     # Put empty text in spanned cols.  
   
     for (my $i = 0; $i < ($colspan -1); $i++) {      for (my $i = 0; $i < ($colspan -1); $i++) {
  push @ {$Apache::londefdef::table[-1]{'content'}[-1] },'';   push @ {$Apache::londefdef::table[-1]{'content'}[-1] },'';
     }      }
       for (my $r = 0; $r < $rowspan; $r++) {
    $Apache::londefdef::table[-1]{'colspan'}[$current_row+$r][$current_column] = $colspan;
    # Put empty text in spanned cols.
   
       }
   
   
   
     return '';      return '';
Line 3179  sub start_pre { Line 3195  sub start_pre {
  $currentstring .= $token->[4];   $currentstring .= $token->[4];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  $currentstring .= '\begin{verbatim}';   $currentstring .= '\begin{verbatim}';
  &Apache::lonxml::disable_LaTeX_substitutions;   &Apache::lonxml::disable_LaTeX_substitutions();
     }       } 
     return $currentstring;      return $currentstring;
 }  }
Line 3191  sub end_pre { Line 3207  sub end_pre {
  $currentstring .= $token->[2];   $currentstring .= $token->[2];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  $currentstring .= '\end{verbatim}';   $currentstring .= '\end{verbatim}';
  &Apache::lonxml::enable_LaTeX_substitutions;   &Apache::lonxml::enable_LaTeX_substitutions();
     }      }
     return $currentstring;      return $currentstring;
 }  }

Removed from v.1.318  
changed lines
  Added in v.1.320


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>