Diff for /loncom/xml/londefdef.pm between versions 1.35 and 1.43

version 1.35, 2001/12/07 18:46:00 version 1.43, 2002/02/21 04:29:27
Line 2 Line 2
 # Tags Default Definition Module   # Tags Default Definition Module 
 #  #
 # $Id$  # $Id$
   # 
 #  #
 # Copyright Michigan State University Board of Trustees  # Copyright Michigan State University Board of Trustees
 #  #
Line 39 Line 40
 #  #
 # last modified 06/26/00 by Alexander Sakharuk  # last modified 06/26/00 by Alexander Sakharuk
 # 11/6,11/30,02/01/01,5/4 Gerd Kortemeyer  # 11/6,11/30,02/01/01,5/4 Gerd Kortemeyer
   # 01/18 Alex Sakharuk
   
 package Apache::londefdef;   package Apache::londefdef; 
   
 use strict;  use strict;
 use Apache::lonxml;  use Apache::lonxml;
   
 sub 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'));      &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'));
   
 }  }
   
Line 70  sub start_m { Line 72  sub start_m {
   if ($target eq 'web') {    if ($target eq 'web') {
     my $inside = &Apache::lonxml::get_all_text("/m",$$parser[-1]);      my $inside = &Apache::lonxml::get_all_text("/m",$$parser[-1]);
     $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);
     if ($eval eq 'on') {      if ($eval eq 'on') {
       $inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);        $inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);
       #&Apache::lonxml::debug("M is evaulated to:$inside:");        #&Apache::lonxml::debug("M is evaulated to:$inside:");
     }      }
     $currentstring = &Apache::lontexconvert::converted(\$inside);      $currentstring = &Apache::lontexconvert::converted(\$inside);
       if ($Apache::lontexconvert::errorstring) {
         &Apache::lonxml::warning("tth error: ".
          $Apache::lontexconvert::errorstring);
         $Apache::lontexconvert::errorstring='';
       }
     #&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 = "";
Line 97  sub end_m { Line 104  sub end_m {
       sub start_html {        sub start_html {
     my ($target,$token) = @_;      my ($target,$token) = @_;
             my $currentstring = '';              my $currentstring = '';
       if ($ENV{'browser.mathml'}) {
         &tth::ttminit();
       } else {
         &tth::tthinit();
       }
             if ($target eq 'web') {              if ($target eq 'web') {
               $currentstring = &Apache::lonxml::xmlbegin().                $currentstring = &Apache::lonxml::xmlbegin().
                                &Apache::lonxml::fontsettings();                                      &Apache::lonxml::fontsettings();     
Line 110  sub end_m { Line 122  sub end_m {
                                  \setlength{\parindent}{20pt}                                   \setlength{\parindent}{20pt}
                                  \setlength{\marginparwidth}{90pt}                                   \setlength{\marginparwidth}{90pt}
                                  \setlength{\textfloatsep}{8pt plus 2.0pt minus 4.0pt}                                   \setlength{\textfloatsep}{8pt plus 2.0pt minus 4.0pt}
                                  \newcommand{\keephidden}[1]{}';                                   \newcommand{\keephidden}[1]{}           
                                    \usepackage[dvips]{graphicx}';
     }      }
    return $currentstring;     return $currentstring;
  }   }
Line 312  sub end_m { Line 325  sub end_m {
       }        }
 #-- <body> tag  #-- <body> tag
         sub start_body {          sub start_body {
     my ($target,$token) = @_;              my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
   #    my ($target,$token) = @_;
             my $currentstring = '';              my $currentstring = '';
             if ($target eq 'web') {              if ($target eq 'web') {
       if (!$Apache::lonxml::registered) {        if (!$Apache::lonxml::registered) {
Line 337  sub end_m { Line 351  sub end_m {
  &Apache::lonxml::unloadevents();   &Apache::lonxml::unloadevents();
   
       $currentstring .= '<'.$token->[1];        $currentstring .= '<'.$token->[1];
       map {        foreach (keys %{$token->[2]}) {
  $currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"';         $currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"';
       } keys %{$token->[2]};        }
       $currentstring.='>';        $currentstring.='>';
         if ($ENV{'request.state'} ne 'published') {
    $currentstring.=(<<EDITBUTTON);
    <form method="post">
    <input type="submit" name="showmode" value="Edit" />
    </form>
   EDITBUTTON
         }
            } elsif ($target eq 'tex') {             } elsif ($target eq 'tex') {
               $currentstring = '\begin{document}';                  $currentstring = '\begin{document}';  
     }       } 
Line 509  sub end_m { Line 530  sub end_m {
             if ($target eq 'web') {              if ($target eq 'web') {
        $currentstring .= $token->[4];         $currentstring .= $token->[4];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  $currentstring .= '\large{\textbf';   $currentstring .= '\large{\textbf{';
     }       } 
            return $currentstring;             return $currentstring;
  }   }
Line 818  sub end_m { Line 839  sub end_m {
             if ($target eq 'web') {              if ($target eq 'web') {
        $currentstring .= $token->[4];         $currentstring .= $token->[4];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  $currentstring .= '\\';   $currentstring .= '\\\\';
     } elsif ($target eq 'latexsource') {      } elsif ($target eq 'latexsource') {
  $currentstring .= '\\';   $currentstring .= '\\';
     }       } 
Line 839  sub end_m { Line 860  sub end_m {
             if ($target eq 'web') {              if ($target eq 'web') {
        $currentstring .= $token->[4];         $currentstring .= $token->[4];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  $currentstring .= '\large{;  
     } elsif ($target eq 'latexsource') {  
  $currentstring .= '\large{';   $currentstring .= '\large{';
       } elsif ($target eq 'latexsource') {
    $currentstring .= '{\Large ';
     }        }  
            return $currentstring;             return $currentstring;
  }   }
Line 864  sub end_m { Line 885  sub end_m {
             if ($target eq 'web') {              if ($target eq 'web') {
        $currentstring .= $token->[4];         $currentstring .= $token->[4];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  $currentstring .= '\footnotesize{';   $currentstring .= '{\footnotesize ';
     } elsif ($target eq 'latexsource') {      } elsif ($target eq 'latexsource') {
  $currentstring .= '\footnotesize{';   $currentstring .= '{\footnotesize ';
     }       } 
            return $currentstring;             return $currentstring;
  }   }
Line 1105  sub end_m { Line 1126  sub end_m {
             if ($target eq 'web') {              if ($target eq 'web') {
               $currentstring = $token->[4];                     $currentstring = $token->[4];     
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
               $currentstring = " \\begin{itemize} ";                  $currentstring = '\begin{itemize}';  
     }       } 
    return $currentstring;     return $currentstring;
  }   }
Line 1115  sub end_m { Line 1136  sub end_m {
             if ($target eq 'web') {              if ($target eq 'web') {
               $currentstring = $token->[2];                     $currentstring = $token->[2];     
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
               $currentstring = " \\end{itemize}";                  $currentstring = '\end{itemize}';  
     }       } 
    return $currentstring;     return $currentstring;
  }   }
Line 1168  sub end_m { Line 1189  sub end_m {
             if ($target eq 'web') {              if ($target eq 'web') {
               $currentstring = $token->[4];                     $currentstring = $token->[4];     
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
               $currentstring = " \\begin{enumerate} ";                  $currentstring = '\begin{enumerate}';  
     }       } 
    return $currentstring;     return $currentstring;
  }   }
Line 1178  sub end_m { Line 1199  sub end_m {
             if ($target eq 'web') {              if ($target eq 'web') {
               $currentstring = $token->[2];                     $currentstring = $token->[2];     
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
               $currentstring = " \\end{enumerate}";                  $currentstring = '\end{enumerate}';  
     }       } 
    return $currentstring;     return $currentstring;
  }   }
Line 1189  sub end_m { Line 1210  sub end_m {
             if ($target eq 'web') {              if ($target eq 'web') {
               $currentstring = $token->[4];                     $currentstring = $token->[4];     
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
               $currentstring = " \\begin{description} ";                  $currentstring = '\begin{description}';  
     }       } 
    return $currentstring;     return $currentstring;
  }   }
Line 1199  sub end_m { Line 1220  sub end_m {
             if ($target eq 'web') {              if ($target eq 'web') {
               $currentstring = $token->[2];                     $currentstring = $token->[2];     
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
               $currentstring = " \\end{description}";                  $currentstring = '\end{description}';  
     }       } 
    return $currentstring;     return $currentstring;
  }   }
Line 1210  sub end_m { Line 1231  sub end_m {
             if ($target eq 'web') {              if ($target eq 'web') {
               $currentstring = $token->[4];                     $currentstring = $token->[4];     
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
               $currentstring = "\\item[ ";                  $currentstring = '\item[';  
     }       } 
    return $currentstring;     return $currentstring;
  }   }
Line 1220  sub end_m { Line 1241  sub end_m {
             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 1248  sub end_m { Line 1269  sub end_m {
             if ($target eq 'web') {              if ($target eq 'web') {
               $currentstring = $token->[4];                     $currentstring = $token->[4];     
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
               $currentstring = "";                  $currentstring = '';  
     }       } 
    return $currentstring;     return $currentstring;
  }   }
Line 1258  sub end_m { Line 1279  sub end_m {
             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 1279  sub end_m { Line 1300  sub end_m {
             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 1300  sub end_m { Line 1321  sub end_m {
             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;
  }   }
 #-- <img> tag  #-- <img> tag
   
         sub start_img {          sub start_img {
     my ($target,$token) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
             $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=                 $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=   
                                         $token->[2]->{'src'};                                          $token->[2]->{'src'};
             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 = " \\begin{figure} ";          my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval);
     }         my $file;
    return $currentstring;        my $path;
                 if ($src =~ m!(.*)/([^/]*)$!) {
    $file = $2;
    $path = $1;
    if ($path=~m:^/:) {
     $path = '/home/httpd/html'.$path;
    } elsif ($path =~ /^\./) {
     $path = $Apache::lonxml::pwd[-1].'/'.$path;
    } else {
     #else it is a full url don't print
     $path = undef;
    }
         } else {
    $path = $Apache::lonxml::pwd[-1];
    $file = $src;
         }
         $file=~s/(\.gif|\.jpg)$/\.eps/;
         if ($path) {
    $currentstring = '\graphicspath{{'.$path.'}}\fbox{\includegraphics{'.$file.'}}';
         } else {
    $currentstring = 'See the image at \tt{'.$src.'}';
         }
       }
       return $currentstring;
  }   }
         sub end_img {          sub end_img {
     my ($target,$token) = @_;      my ($target,$token) = @_;
             my $currentstring = '';              my $currentstring = '';
             if ($target eq 'web') {              if ($target eq 'web') {
               $currentstring = $token->[2];                     $currentstring = $token->[2];  
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
               $currentstring = " \\end{figure}";                  $currentstring = '';  
     }       } 
    return $currentstring;     return $currentstring;
  }   }
Line 1442  sub end_m { Line 1485  sub end_m {
   }    }
   return $currentstring;    return $currentstring;
  }   }
   #-- <pre>
    sub start_pre {
       my ($target,$token) = @_;
               my $currentstring = '';
               if ($target eq 'web') {
          $currentstring .= $token->[4];
       } elsif ($target eq 'tex') {
    $currentstring .= '\begin{verbatim}';
       } 
              return $currentstring;
    }
           sub end_pre {
       my ($target,$token) = @_;
               my $currentstring = '';
               if ($target eq 'web') {
          $currentstring .= $token->[2];
       } elsif ($target eq 'tex') {
    $currentstring .= '\end{verbatim}';
       }
              return $currentstring;
    }
 1;  1;
 __END__  __END__

Removed from v.1.35  
changed lines
  Added in v.1.43


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