Diff for /loncom/xml/londefdef.pm between versions 1.44 and 1.50

version 1.44, 2002/02/26 21:44:45 version 1.50, 2002/04/04 19:20:33
Line 50  use Apache::lonxml; Line 50  use Apache::lonxml;
   
 BEGIN {  BEGIN {
   
     &Apache::lonxml::register('Apache::londefdef',('m','html','head','map','select','option','input','textarea','form','meta','title','body','center','b','strong','table','dt','h1','h2','h3','h4','h5','h6','cite','i','address','dd','dl','dir','ol','ul','menu','dfn','kbd','tt','code','em','q','p','br','big','small','basefont','font','s','sub','strike','sup','hr','a','li','u','output','param','applet','img','embed','tr','td','allow','frameset','pre','insert'));      &Apache::lonxml::register('Apache::londefdef',('m','html','head','map','select','option','input','textarea','form','meta','title','body','center','b','strong','dt','h1','h2','h3','h4','h5','h6','cite','i','address','dd','dl','dir','ol','ul','menu','dfn','kbd','tt','code','em','q','p','br','big','small','basefont','font','s','sub','strike','sup','hr','a','li','u','output','param','applet','img','embed','allow','frameset','pre','insert','externallink','table'));
   
 }  }
   
Line 115  sub end_m { Line 115  sub end_m {
                                &Apache::lonxml::fontsettings();                                      &Apache::lonxml::fontsettings();     
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
       $currentstring .= '\documentclass[letterpaper]{article}        $currentstring .= '\documentclass[letterpaper]{article}
                                  \setlength{\oddsidemargin}{-40pt}  
                                  \setlength{\evensidemargin}{-60pt}  
                                  \setlength{\topmargin}{200pt}  
                                  \setlength{\textwidth}{4.4in}  
                                  \setlength{\textheight}{6.8in}  
                                  \setlength{\parindent}{20pt}  
                                  \setlength{\marginparwidth}{90pt}  
                                  \setlength{\textfloatsep}{8pt plus 2.0pt minus 4.0pt}  
                                  \newcommand{\keephidden}[1]{}                                              \newcommand{\keephidden}[1]{}           
                                  \usepackage[dvips]{graphicx}                                   \usepackage[dvips]{graphicx}
                                  \usepackage{epsfig}';                                   \usepackage{epsfig}';
Line 150  sub end_m { Line 142  sub end_m {
     my ($target,$token) = @_;      my ($target,$token) = @_;
             my $currentstring = '';              my $currentstring = '';
             if ($target eq 'web') {              if ($target eq 'web') {
               $currentstring = &Apache::lonxml::registerurl().                $currentstring = &Apache::lonxml::registerurl(undef,$target).
                                $token->[2];                                     $token->[2];    
             }               } 
    return $currentstring;     return $currentstring;
Line 332  sub end_m { Line 324  sub end_m {
             my $currentstring = '';              my $currentstring = '';
             if ($target eq 'web') {              if ($target eq 'web') {
       if (!$Apache::lonxml::registered) {        if (!$Apache::lonxml::registered) {
  $currentstring.='<head>'.&Apache::lonxml::registerurl().'</head>';   $currentstring.='<head>'.
       &Apache::lonxml::registerurl(undef,$target).'</head>';
       }        }
       my $onLoad='';        my $onLoad='';
       foreach my $key (keys(%{$token->[2]})) {        foreach my $key (keys(%{$token->[2]})) {
Line 360  sub end_m { Line 353  sub end_m {
       if ($ENV{'request.state'} ne 'published') {        if ($ENV{'request.state'} ne 'published') {
  $currentstring.=(<<EDITBUTTON);   $currentstring.=(<<EDITBUTTON);
  <form method="post">   <form method="post">
  <input type="submit" name="showmode" value="Edit" />   <input type="submit" name="editmode" value="Edit" />
  </form>   </form>
 EDITBUTTON  EDITBUTTON
       }        }
Line 1266  EDITBUTTON Line 1259  EDITBUTTON
  }   }
 #-- <table> tag  #-- <table> tag
         sub start_table {          sub start_table {
     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 = '';     my $border = &Apache::lonxml::get_param('border',$parstack,$safeeval);
    my $tabletext=&Apache::lonxml::get_all_text("/table",$$parser[$#$parser]);
    my %mystyle;
    $tabletext = &Apache::lonxml::xmlparse('tex',$tabletext,'',%mystyle);       
    unless (defined $border) { $border = 0; }
    my $hinc = '';
                   my $vinc = '';   
    my $vvinc = '';
    if ($border) { $hinc = '\hline '; $vinc =  '&'; $vvinc =  '|';}
    my @raws = ();
    my @columns = ();
    my $counter_columns;
   #serch row
    $_ = $tabletext;
    while (m/<tr\s*([^>]*)>/) {
       push @raws,$1;
                       $tabletext =~ s/<tr\s*([^>]*)>/$hinc/;
   #serch and convert column
       my $boundary = index($tabletext,'</tr>',0);
       my $textchunk = substr($tabletext,0,$boundary); 
       $_ = $textchunk;
       $counter_columns = 0;
       while (m/<td\s*([^>]*)>/) {
    push @columns,$1;
    $counter_columns++;
    $textchunk =~ s/<\/td>\s*<td\s*([^>]*)>/$vinc/;
    $textchunk =~ s/<td\s*([^>]*)>//;
    $textchunk =~ s/<\/td>//;
    $_ = $textchunk;
       }
       substr($tabletext,0,$boundary) = $textchunk;
   #convert row
       $tabletext =~ s/<\/tr>/\\\\/;
       $_ = $tabletext;
    }
    my $default_value = '';
    if ($raws[1] eq 'left') {
       $default_value = 'l';
    } elsif ($raws[1] eq 'center') {
       $default_value = 'c';
    } elsif ($raws[1] eq 'right') {
       $default_value = 'r';
    } else {
        $default_value = 'c';
    }
    my $header_of_table = '{'.$vvinc;
    my $in;
    for ($in=0;$in<=$counter_columns;$in++) {
       if ($columns[$in] eq 'left') {
    $header_of_table .= 'l'.$vvinc;
       } elsif ($columns[$in] eq 'center') {
    $header_of_table .= 'c'.$vvinc;
       } elsif ($columns[$in] eq 'right') {
    $header_of_table .= 'r'.$vvinc;
       } else {
          $header_of_table .= $default_value.$vvinc;
       }
    }
    $header_of_table .= '}';
    $currentstring .= '\begin{tabular}'.$header_of_table.$tabletext.$hinc.'\end{tabular}';
     }       } 
    return $currentstring;     return $currentstring;
  }   }
Line 1280  EDITBUTTON Line 1332  EDITBUTTON
             my $currentstring = '';              my $currentstring = '';
             if ($target eq 'web') {              if ($target eq 'web') {
               $currentstring = $token->[2];                     $currentstring = $token->[2];     
     } elsif ($target eq 'tex') {  
               $currentstring = '';    
     }   
    return $currentstring;  
  }  
 #-- <tr> tag  
         sub start_tr {  
     my ($target,$token) = @_;  
             my $currentstring = '';  
             if ($target eq 'web') {  
               $currentstring = $token->[4];       
     } elsif ($target eq 'tex') {  
       $currentstring = '';  
     }   
    return $currentstring;  
  }  
         sub end_tr {  
     my ($target,$token) = @_;  
             my $currentstring = '';  
             if ($target eq 'web') {  
               $currentstring = $token->[2];       
     } elsif ($target eq 'tex') {  
               $currentstring = '';    
     }   
    return $currentstring;  
  }  
 #-- <td> tag  
         sub start_td {  
     my ($target,$token) = @_;  
             my $currentstring = '';  
             if ($target eq 'web') {  
               $currentstring = $token->[4];  
     } elsif ($target eq 'tex') {  
       $currentstring = '';  
     }   
    return $currentstring;  
  }  
         sub end_td {  
     my ($target,$token) = @_;  
             my $currentstring = '';  
             if ($target eq 'web') {  
               $currentstring = $token->[2];  
     } elsif ($target eq 'tex') {  
               $currentstring = '';  
     }      }
    return $currentstring;     return $currentstring;
  }   }
Line 1337  EDITBUTTON Line 1345  EDITBUTTON
     if ($target eq 'web') {      if ($target eq 'web') {
               $currentstring = $token->[4];                     $currentstring = $token->[4];     
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
 #<<<<<<< londefdef.pm  
 #                my $durty = $token->[2]->{'src'};  
 #                $durty =~ s!(^.*)/(.*)$!$1/!;  
 #                my $durtytwo = $2;  
 # $currentstring = '\graphicspath{{/home/httpd/html'.$durty.'}}\fbox{\includegraphics{'.$durtytwo.'}}';  
 #    }  
 #   return $currentstring;  
 #=======  
       my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval);        my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval);
       my $file;        my $file;
       my $path;        my $path;
Line 1365  EDITBUTTON Line 1365  EDITBUTTON
       }        }
       $file=~s/(\.gif|\.jpg)$/\.eps/;        $file=~s/(\.gif|\.jpg)$/\.eps/;
       if ($path) {        if ($path) {
  $currentstring = '\graphicspath{{'.$path.'}}\fbox{\includegraphics{'.$file.'}}';   $currentstring = '\graphicspath{{'.$path.'/}}\fbox{\includegraphics{'.$file.'}}';
       } else {        } else {
  $currentstring = 'See the image at \tt{'.$src.'}';   $currentstring = 'See the image at \tt{'.$src.'}';
       }        }
     }      }
     return $currentstring;      return $currentstring;
 #>>>>>>> 1.43  
  }   }
         sub end_img {          sub end_img {
     my ($target,$token) = @_;      my ($target,$token) = @_;
Line 1412  sub end_applet { Line 1411  sub end_applet {
   
 #-- <embed> tag  #-- <embed> tag
   
 sub start_embed {  sub start_embed {    
       
     my ($target,$token) = @_;      my ($target,$token) = @_;
     $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=      $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
  $token->[2]->{'src'};   $token->[2]->{'src'};
Line 1484  sub start_embed { Line 1482  sub start_embed {
   my $currentstring = '';    my $currentstring = '';
   if ($target eq 'web') {     if ($target eq 'web') { 
     if (!$Apache::lonxml::registered) {      if (!$Apache::lonxml::registered) {
       $currentstring.='<head>'.&Apache::lonxml::registerurl().'</head>';        $currentstring.='<head>'.
     &Apache::lonxml::registerurl(undef,$target).'</head>';
     }      }
     $currentstring .= $token->[4];      $currentstring .= $token->[4];
   }    }
Line 1521  sub start_embed { Line 1520  sub start_embed {
  }   }
 #-- <insert>  #-- <insert>
  sub start_insert {   sub start_insert {
     my ($target,$token) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
             my $currentstring = '';              my $currentstring = '';
             if ($target eq 'web') {              if ($target eq 'web') {
        $currentstring .= '<b>'.$token->[2]->{'display'}.'</b>';;   my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval);
          $currentstring .= '<b>'.$display.'</b>';;
     }      }
            return $currentstring;             return $currentstring;
  }   }
Line 1532  sub start_embed { Line 1532  sub start_embed {
     my ($target,$token) = @_;      my ($target,$token) = @_;
             my $currentstring = '';              my $currentstring = '';
             if ($target eq 'web') {              if ($target eq 'web') {
          $currentstring .= '';
       }
              return $currentstring;
    }
   #-- <externallink>
    sub start_externallink {
       my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
               my $currentstring = '';
               if ($target eq 'web') {
    my $display = &Apache::lonxml::get_param('display',$parstack,$safeeval);
          $currentstring .= '<b>'.$display.'</b>';;
       }
              return $currentstring;
    }
           sub end_externallink {
       my ($target,$token) = @_;
               my $currentstring = '';
               if ($target eq 'web') {
        $currentstring .= '';         $currentstring .= '';
     }      }
            return $currentstring;             return $currentstring;

Removed from v.1.44  
changed lines
  Added in v.1.50


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