Diff for /loncom/xml/londefdef.pm between versions 1.276 and 1.277

version 1.276, 2005/07/05 18:59:03 version 1.277, 2005/07/07 10:09:50
Line 565  EDITBUTTON Line 565  EDITBUTTON
   
 sub end_body {  sub end_body {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # Close off unclosed <p>
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring = &Apache::lonxml::xmlend($target,$parser);   $currentstring .= &Apache::lonxml::xmlend($target,$parser);
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  $currentstring = '\strut\newline\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\newline\noindent \end{document}';     $currentstring .= '\strut\newline\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\newline\noindent \end{document}';  
     }       } 
     return $currentstring;      return $currentstring;
 }  }
Line 577  sub end_body { Line 577  sub end_body {
 #-- <center> tag (end tag required)  #-- <center> tag (end tag required)
 sub start_center {  sub start_center {
     my ($target,$token) = @_;      my ($target,$token) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # Close off any prior para.
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring = $token->[4];        $currentstring .= $token->[4];     
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  $currentstring = '\begin{center}';     $currentstring .= '\begin{center}';  
     }      }
     return $currentstring;      return $currentstring;
 }  }
Line 646  sub end_strong { Line 646  sub end_strong {
 #-- <h1> tag (end tag required)  #-- <h1> tag (end tag required)
 sub start_h1 {  sub start_h1 {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # Close off any prior para.
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring .= $token->[4];   $currentstring .= $token->[4];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
Line 663  sub start_h1 { Line 663  sub start_h1 {
  if (not defined $TeXsize) {$TeXsize="large";}   if (not defined $TeXsize) {$TeXsize="large";}
  $currentstring .= '\strut\newline '.$pre.'{\\'.$TeXsize.' \textbf{';    $currentstring .= '\strut\newline '.$pre.'{\\'.$TeXsize.' \textbf{'; 
     } elsif ($target eq 'meta') {      } elsif ($target eq 'meta') {
  $currentstring='<subject>';   $currentstring.='<subject>';
  &start_output($target);   &start_output($target);
     }      }
     return $currentstring;      return $currentstring;
Line 695  sub end_h1 { Line 695  sub end_h1 {
 #-- <h2> tag  #-- <h2> tag
 sub start_h2 {  sub start_h2 {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # Close off any prior para.
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring .= $token->[4];   $currentstring .= $token->[4];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
Line 738  sub end_h2 { Line 738  sub end_h2 {
 #-- <h3> tag  #-- <h3> tag
 sub start_h3 {  sub start_h3 {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # Close off any prior para.
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring .= $token->[4];   $currentstring .= $token->[4];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
Line 781  sub end_h3 { Line 781  sub end_h3 {
 #-- <h4> tag  #-- <h4> tag
 sub start_h4 {  sub start_h4 {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # Close off any prior para.
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring .= $token->[4];   $currentstring .= $token->[4];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
Line 824  sub end_h4 { Line 824  sub end_h4 {
 #-- <h5> tag  #-- <h5> tag
 sub start_h5 {  sub start_h5 {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # Close off any prior paras.
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring .= $token->[4];   $currentstring .= $token->[4];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
Line 867  sub end_h5 { Line 867  sub end_h5 {
 #-- <h6> tag  #-- <h6> tag
 sub start_h6 {  sub start_h6 {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # Close off any prior paras.
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring .= $token->[4];   $currentstring .= $token->[4];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
Line 1114  sub end_q { Line 1114  sub end_q {
     return $currentstring;      return $currentstring;
 }  }
   
   #  <p> is a bit strange since it does not require a closing </p>
   #  However in latex, we must often output closing stuff to end
   #  environments and {}'s etc.  Therefore we do all the work
   #  of figuring out the ending strings in the start tag processing,
   #  and provide a mechanism to output the stop text external
   #  to tag processing.
   #
   {
   
       my $closing_string = ''; # String required to close <p>
   
 #-- <p> tag (end tag optional)  #-- <p> tag (end tag optional)
 #optional attribute - align="center|left|right"  #optional attribute - align="center|left|right"
 sub start_p {  sub start_p {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # close off prior para if in progress.
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring .= $token->[4];   $currentstring .= $token->[4];
    $closing_string = '</p>'; # Not sure this is correct.
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);   my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
  if ($align eq 'center') {   if ($align eq 'center') {
     $currentstring='\begin{center}\par';      $currentstring .='\begin{center}\par';
       $closing_string = '\end{center}';
  } elsif ($align eq 'right') {   } elsif ($align eq 'right') {
     $currentstring='\makebox['.$env{'form.textwidth'}.']{\hfill\llap{';      $currentstring.='\makebox['.$env{'form.textwidth'}.']{\hfill\llap{';
       $closing_string= '}}';
  } elsif ($align eq 'left') {   } elsif ($align eq 'left') {
     $currentstring='\noindent\makebox['.$env{'form.textwidth'}.']{\rlap{';      $currentstring.='\noindent\makebox['.$env{'form.textwidth'}.']{\rlap{';
       $closing_string = '}\hfill}';
  } else {   } else {
             $currentstring='\par ';              $currentstring.='\par ';
       $closing_string = '\strut\\\\\strut';
         }          }
  my $signal=1;#<p> does not work inside <b>...</b>    my $signal=1;#<p> does not work inside <b>...</b> 
  foreach my $tag (@$tagstack) {if (lc($tag) eq 'b') {$signal=0;}   foreach my $tag (@$tagstack) {
  if (!$signal) {$currentstring = '';}      if (lc($tag) eq 'b') {
    $signal=0;
       }
    }
    if (!$signal) {
       $currentstring = &end_p; # Just close the prior? Not sure this is correct
       $closing_string = '';    # Probably correct?
  }   }
     }  
     return $currentstring;  
 }  
   
 sub end_p {  
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;  
     my $currentstring = '';  
     if ($target eq 'web') {  
  $currentstring .= $token->[2];  
     } elsif ($target eq 'tex') {  
  my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);  
  if (not defined $align) {  
     $currentstring.='\strut\\\\\strut ';  
  } elsif ($align eq 'center') {  
     $currentstring .= '\end{center}';  
  } elsif ($align eq 'right') {  
     $currentstring .= '}}';  
  } elsif ($align eq 'left') {  
     $currentstring .= '}\hfill}';  
  }   
     }      }
     return $currentstring;      return $currentstring;
 }  }
   #
   #  End paragraph processing just requires that we output the
   #  closing string that was saved and blank it.
   sub end_p {
       my $current_string = $closing_string;
       $closing_string = ''; # Not in a para anymore.
       return $current_string;
   
   }
   }
 #-- <br> tag (end tag forbidden)  #-- <br> tag (end tag forbidden)
 sub start_br {  sub start_br {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
Line 1405  sub end_sup { Line 1417  sub end_sup {
 #-- <hr> tag (end tag forbidden)  #-- <hr> tag (end tag forbidden)
 sub start_hr {  sub start_hr {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # End enclosing para.
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring .= $token->[4];   $currentstring .= $token->[4];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
Line 1445  sub end_hr { Line 1457  sub end_hr {
 #-- <div> tag (end tag required)  #-- <div> tag (end tag required)
 sub start_div {  sub start_div {
     my ($target,$token) = @_;      my ($target,$token) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # Close enclosing para.
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring .= $token->[4];   $currentstring .= $token->[4];
     }       } 
Line 1527  sub start_li { Line 1539  sub start_li {
   
 sub end_li {  sub end_li {
     my ($target,$token) = @_;      my ($target,$token) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # In case there's a <p> in the <li>
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring = $token->[2];        $currentstring .= $token->[2];     
     }       } 
     return $currentstring;      return $currentstring;
 }  }
Line 1563  sub end_u { Line 1575  sub end_u {
 #-- <ul> tag (end tag required)  #-- <ul> tag (end tag required)
 sub start_ul {  sub start_ul {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # Close off enclosing list.
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring = $token->[4];        $currentstring .= $token->[4];     
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  my $TeXtype=&Apache::lonxml::get_param('type',$parstack,$safeeval,undef,0);   my $TeXtype=&Apache::lonxml::get_param('type',$parstack,$safeeval,undef,0);
  $Apache::londefdef::list_index=0;   $Apache::londefdef::list_index=0;
Line 1630  sub end_menu { Line 1642  sub end_menu {
 #-- <dir> tag (end tag required)  #-- <dir> tag (end tag required)
 sub start_dir {  sub start_dir {
     my ($target,$token) = @_;      my ($target,$token) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # In case there's a <p> prior to the list.
     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 1653  sub end_dir { Line 1665  sub end_dir {
 #-- <ol> tag (end tag required)  #-- <ol> tag (end tag required)
 sub start_ol {  sub start_ol {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # In case there's a <p> prior to the list.
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring = $token->[4];        $currentstring .= $token->[4];     
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  $Apache::londefdef::list_index=0;   $Apache::londefdef::list_index=0;
  my $type=&Apache::lonxml::get_param('type',$parstack,$safeeval,undef,0);   my $type=&Apache::lonxml::get_param('type',$parstack,$safeeval,undef,0);
Line 1707  sub end_ol { Line 1719  sub end_ol {
 #-- <dl> tag (end tag required)  #-- <dl> tag (end tag required)
 sub start_dl {  sub start_dl {
     my ($target,$token) = @_;      my ($target,$token) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # In case there's a <p> unclosed prior to the list.
     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}';
  $Apache::londefdef::DL++;   $Apache::londefdef::DL++;
  push(@Apache::londefdef::description,[]);   push(@Apache::londefdef::description,[]);
  $Apache::londefdef::DD[$Apache::londefdef::DL]=0;   $Apache::londefdef::DD[$Apache::londefdef::DL]=0;
Line 1814  sub end_dd { Line 1826  sub end_dd {
 }  }
   
 #-- <table> tag (end tag required)  #-- <table> tag (end tag required)
   #       <table> also ends any prior <p> that is not closed.
   #               but, unless I allow <p>'s to nest, that's the
   #               only way I could think of to allow <p> in 
   #               <tr> <th> bodies
   #
 #list of supported attributes: border,width,TeXwidth  #list of supported attributes: border,width,TeXwidth
 sub start_table {  sub start_table {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my ($textwidth,$currentstring)=('','');      my $textwidth = '';
       my $currentstring = &end_p;
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring = $token->[4];        $currentstring .= $token->[4];     
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  my $aa = {};   my $aa = {};
  push @Apache::londefdef::table, $aa;    push @Apache::londefdef::table, $aa; 
Line 1883  sub start_table { Line 1901  sub start_table {
         $Apache::londefdef::table[-1]{'minlen'}=[];          $Apache::londefdef::table[-1]{'minlen'}=[];
         $Apache::londefdef::table[-1]{'content'}=[];          $Apache::londefdef::table[-1]{'content'}=[];
         $Apache::londefdef::table[-1]{'align'}=[];          $Apache::londefdef::table[-1]{'align'}=[];
         $currentstring='\keephidden{NEW TABLE ENTRY}';          $currentstring.='\keephidden{NEW TABLE ENTRY}';
    }     }
     return $currentstring;      return $currentstring;
 }  }
Line 2137  sub start_tr { Line 2155  sub start_tr {
                   
 sub end_tr {  sub end_tr {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # Close any pending <p> in the row.
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring = $token->[2];        $currentstring .= $token->[2];     
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  if ($Apache::londefdef::TD_redirection) {   if ($Apache::londefdef::TD_redirection) {
     &end_td_tex($parstack,$parser,$safeeval);          &end_td_tex($parstack,$parser,$safeeval);    
Line 2414  sub end_th_tex { Line 2432  sub end_th_tex {
   
 sub end_th {  sub end_th {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # Close any open <p> in the row.
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring = $token->[2];        $currentstring .= $token->[2];     
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
         $Apache::londefdef::TD_redirection =0;          $Apache::londefdef::TD_redirection =0;
  &end_th_tex($parstack,$parser,$safeeval);   &end_th_tex($parstack,$parser,$safeeval);
Line 2795  sub end_allow { Line 2813  sub end_allow {
 #-- <frameset>  #-- <frameset>
 sub start_frameset {  sub start_frameset {
     my ($target,$token) = @_;      my ($target,$token) = @_;
     my $currentstring = '';      my $currentstring = ''; # Close any pending para.
     if ($target eq 'web') {       if ($target eq 'web') { 
  if (!$Apache::lonxml::registered &&   if (!$Apache::lonxml::registered &&
     $env{'request.state'} eq 'published') {      $env{'request.state'} eq 'published') {
Line 2864  sub end_xmp { Line 2882  sub end_xmp {
 #-- <pre> (end tag required)  #-- <pre> (end tag required)
 sub start_pre {  sub start_pre {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # close off pending <p>
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring .= $token->[4];   $currentstring .= $token->[4];
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
Line 2927  sub end_externallink { Line 2945  sub end_externallink {
 #-- <blankspace heigth="">  #-- <blankspace heigth="">
 sub start_blankspace {  sub start_blankspace {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # closes off any unclosed <p>
     if ($target eq 'tex') {      if ($target eq 'tex') {
  my $howmuch = &Apache::lonxml::get_param('heigth',$parstack,$safeeval,undef,1);   my $howmuch = &Apache::lonxml::get_param('heigth',$parstack,$safeeval,undef,1);
  $currentstring .= '\vskip '.$howmuch.' ';   $currentstring .= '\vskip '.$howmuch.' ';
Line 3080  sub end_blink { Line 3098  sub end_blink {
 #-- <blockquote> tag (end tag required)  #-- <blockquote> tag (end tag required)
 sub start_blockquote {  sub start_blockquote {
     my ($target,$token) = @_;      my ($target,$token) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # Close any unclosed <p>
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring = $token->[4];        $currentstring .= $token->[4];     
     }       } 
     return $currentstring;      return $currentstring;
 }  }
Line 3403  sub end_marquee { Line 3421  sub end_marquee {
 #-- <multicol> tag (end tag required)  #-- <multicol> tag (end tag required)
 sub start_multicol {  sub start_multicol {
     my ($target,$token) = @_;      my ($target,$token) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # Close any pending <p>
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring = $token->[4];        $currentstring .= $token->[4];     
     }       } 
     return $currentstring;      return $currentstring;
 }  }
Line 3601  sub end_server { Line 3619  sub end_server {
 #-- <spacer> tag (end tag forbidden)  #-- <spacer> tag (end tag forbidden)
 sub start_spacer {  sub start_spacer {
     my ($target,$token) = @_;      my ($target,$token) = @_;
     my $currentstring = '';      my $currentstring = &end_p; # Close off any open <p> tag.
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring = $token->[4];        $currentstring .= $token->[4];     
     }       } 
     return $currentstring;      return $currentstring;
 }  }

Removed from v.1.276  
changed lines
  Added in v.1.277


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