Diff for /loncom/xml/londefdef.pm between versions 1.69 and 1.77

version 1.69, 2002/07/11 14:40:14 version 1.77, 2002/07/24 20:23:21
Line 48  use Apache::lonnet; Line 48  use Apache::lonnet;
 use strict;  use strict;
 use Apache::lonxml;  use Apache::lonxml;
 use Apache::File();  use Apache::File();
   use Image::Magick;
   
 BEGIN {  BEGIN {
   
Line 73  sub start_m { Line 74  sub start_m {
   my $currentstring = '';    my $currentstring = '';
   if ($target eq 'web') {    if ($target eq 'web') {
     $Apache::lonxml::prevent_entity_encode++;      $Apache::lonxml::prevent_entity_encode++;
     my $inside = &Apache::lonxml::get_all_text("/m",$$parser[-1]);      my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
     $inside ='\\documentstyle{article}'.$inside;      $inside ='\\documentstyle{article}'.$inside;
     &Apache::lonxml::debug("M is starting with:$inside:");      &Apache::lonxml::debug("M is starting with:$inside:");
     my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval);      my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval);
Line 89  sub start_m { Line 90  sub start_m {
     }      }
     #&Apache::lonxml::debug("M is ends with:$currentstring:");      #&Apache::lonxml::debug("M is ends with:$currentstring:");
   } elsif ($target eq 'tex') {    } elsif ($target eq 'tex') {
     $currentstring = "";      $currentstring = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
       if ($currentstring=~/\s*\\\\\s*/) {$currentstring = ' \vskip 0 mm ';}
     } else {
       my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
   }    }
   return $currentstring;    return $currentstring;
 }  }
Line 119  sub end_m { Line 123  sub end_m {
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
       @Apache::londefdef::table = ();        @Apache::londefdef::table = ();
       $currentstring .= '\documentclass[letterpaper]{article}        $currentstring .= '\documentclass[letterpaper]{article}
                                  \newcommand{\keephidden}[1]{}                                              \newcommand{\keephidden}[1]{}
                                    \renewcommand{\deg}{$^{\circ}$}
                                  \usepackage[dvips]{graphicx}                                   \usepackage[dvips]{graphicx}
                                  \usepackage{epsfig}\usepackage{calc}';                                   \usepackage{epsfig}\usepackage{calc}';
     }      }
Line 834  EDITBUTTON Line 839  EDITBUTTON
  }   }
 #-- <br> tag  #-- <br> tag
         sub start_br {          sub start_br {
     my ($target,$token) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
             my $currentstring = '';              my $currentstring = '';
             if ($target eq 'web') {              if ($target eq 'web') {
        $currentstring .= $token->[4];         $currentstring .= $token->[4];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  $currentstring .= '\vskip 0 mm';   if ($$tagstack[-2] ne 'sub' && $$tagstack[-2] ne 'sup') {
       $currentstring .= '\vskip 0 mm';
    }
     } elsif ($target eq 'latexsource') {      } elsif ($target eq 'latexsource') {
  $currentstring .= '\\';   $currentstring .= '\\';
     }       } 
Line 948  EDITBUTTON Line 955  EDITBUTTON
             if ($target eq 'web') {              if ($target eq 'web') {
        $currentstring .= $token->[4];         $currentstring .= $token->[4];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  $currentstring .= "{\\underline ";   $currentstring .= '\underline{';
     }       } 
            return $currentstring;             return $currentstring;
  }   }
Line 958  EDITBUTTON Line 965  EDITBUTTON
             if ($target eq 'web') {              if ($target eq 'web') {
        $currentstring .= $token->[2];         $currentstring .= $token->[2];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
         $currentstring .= " }";          $currentstring .= '}';
             }              }
            return $currentstring;             return $currentstring;
  }   }
Line 969  EDITBUTTON Line 976  EDITBUTTON
             if ($target eq 'web') {              if ($target eq 'web') {
        $currentstring .= $token->[4];         $currentstring .= $token->[4];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  $currentstring .= "{\\underline ";   $currentstring .= '\underline{';
     }       } 
            return $currentstring;             return $currentstring;
  }   }
Line 979  EDITBUTTON Line 986  EDITBUTTON
             if ($target eq 'web') {              if ($target eq 'web') {
        $currentstring .= $token->[2];         $currentstring .= $token->[2];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
         $currentstring .= " }";          $currentstring .= '}';
             }              }
            return $currentstring;             return $currentstring;
  }   }
Line 1032  EDITBUTTON Line 1039  EDITBUTTON
             if ($target eq 'web') {              if ($target eq 'web') {
        $currentstring .= $token->[4];         $currentstring .= $token->[4];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  $currentstring .= "\\hline ";   $currentstring .= '\vskip 0 mm \noindent\makebox[\textwidth - 8 mm][b]{\hrulefill}';
     }       } 
            return $currentstring;             return $currentstring;
  }   }
Line 1109  EDITBUTTON Line 1116  EDITBUTTON
             if ($target eq 'web') {              if ($target eq 'web') {
        $currentstring .= $token->[4];         $currentstring .= $token->[4];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  $currentstring .= "{\\underline ";   $currentstring .= '\underline{';
     }       } 
            return $currentstring;             return $currentstring;
  }   }
Line 1119  EDITBUTTON Line 1126  EDITBUTTON
             if ($target eq 'web') {              if ($target eq 'web') {
        $currentstring .= $token->[2];         $currentstring .= $token->[2];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
         $currentstring .= " }";          $currentstring .= '}';
             }              }
            return $currentstring;             return $currentstring;
  }   }
Line 1310  EDITBUTTON Line 1317  EDITBUTTON
     chop $output;      chop $output;
     $output .= ' \\\\ ';      $output .= ' \\\\ ';
  }   }
  $Apache::londefdef::table[-1]{'output'} .= $header_of_table.$output.$Apache::londefdef::table[-1]{'hinc'}.'\end{tabular}';                  my @length = split(/,/,$Apache::londefdef::table[-1]{'length'});
                   my $how_many_columns = $#length+1;
                   my $parboxlength = '(\textwidth';
                   for (my $io=0; $io<=$#length;$io++) {
       if ($length[$io] ne '') {
    $parboxlength .= ' - '.$length[$io].' ';
       }
    }
    $parboxlength .= ')/'.$how_many_columns.' - 7 mm';
    $output =~ s/\\parbox{}/\\parbox{$parboxlength}/g;
    $Apache::londefdef::table[-1]{'output'} .= $header_of_table.$output.$Apache::londefdef::table[-1]{'hinc'}.'\end{tabular}\vskip 0 mm ';
  if ($#Apache::londefdef::table > 0) {   if ($#Apache::londefdef::table > 0) {
     $inmemory = $Apache::londefdef::table[-1]{'output'};      $inmemory = $Apache::londefdef::table[-1]{'output'};
     pop @Apache::londefdef::table;      pop @Apache::londefdef::table;
Line 1339  EDITBUTTON Line 1356  EDITBUTTON
  }   }
  push ( @{ $Apache::londefdef::table[-1]{'rowdata'} }, $Apache::londefdef::table[-1]{'hinc'});   push ( @{ $Apache::londefdef::table[-1]{'rowdata'} }, $Apache::londefdef::table[-1]{'hinc'});
  $Apache::londefdef::table[-1]{'counter_columns'} = -1;   $Apache::londefdef::table[-1]{'counter_columns'} = -1;
    $Apache::londefdef::table[-1]{'length'} = ''; #just added
   
     }       } 
    return $currentstring;     return $currentstring;
Line 1379  EDITBUTTON Line 1397  EDITBUTTON
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  my $current_row = $Apache::londefdef::table[-1]{'row_number'};   my $current_row = $Apache::londefdef::table[-1]{'row_number'};
  my $data=&Apache::lonxml::endredirection();   my $data=&Apache::lonxml::endredirection();
  @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= $data.' '.$Apache::londefdef::table[-1]{'vinc'};   if ($data=~m/width\s*=\s*(\d+\.*\d*\s*(mm|cm))/) {                 #just added
                       $Apache::londefdef::table[-1]{'length'} .= $1.',';             #just added
    }                                                                  #just added
    @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{'.$1.'}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'};
     }      }
    return $currentstring;     return $currentstring;
  }   }
Line 1409  EDITBUTTON Line 1430  EDITBUTTON
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  my $current_row = $Apache::londefdef::table[-1]{'row_number'};   my $current_row = $Apache::londefdef::table[-1]{'row_number'};
  my $data=&Apache::lonxml::endredirection();   my $data=&Apache::lonxml::endredirection();
  @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\bf{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'};   if ($data=~m/width\s*=\s*(\d+\.*\d*\s*(mm|cm))/) {                 #just added
                       $Apache::londefdef::table[-1]{'length'} .= $1.',';             #just added
    }                                                                  #just added
    @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{'.$1.'}{\textbf{'.$data.'}} '.$Apache::londefdef::table[-1]{'vinc'};
     }      }
    return $currentstring;     return $currentstring;
  }   }
Line 1428  EDITBUTTON Line 1452  EDITBUTTON
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
       my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval);        my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval);
       $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);        $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
               if ($src=~m/\.(gif|GIF)$/) {                my $image = Image::Magick->new;
   my $gif_file = Apache::File->new($src);                my $current_figure = $image->Read($src);
   binmode ($gif_file);                $width_param = $image->Get('width') * $scaling;;
                   my ($buff,$imagesize);        $height_param = $image->Get('height') * $scaling;;
   read ($gif_file,$buff,6);        undef $image;
                   read ($gif_file,$imagesize,4);  
                   my ($xlsb,$xmsb,$ylsb,$ymsb) = split(//,$imagesize);  
                   my $image_width=ord($xlsb)+ord($xmsb)*256;  
                   my $image_height=ord($ylsb)+ord($ymsb)*256;  
   $width_param = $image_width * $scaling; #default value of the picture's width  
   $height_param = $image_height * $scaling; #default value of the picture's height  
        }  
       my $epssrc = $src;        my $epssrc = $src;
       $epssrc =~ s/(\.gif|\.jpg)$/\.eps/i;        $epssrc =~ s/(\.gif|\.jpg)$/\.eps/i;
       if (not -e $epssrc) {        if (not -e $epssrc) {

Removed from v.1.69  
changed lines
  Added in v.1.77


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