Diff for /loncom/xml/londefdef.pm between versions 1.278 and 1.279

version 1.278, 2005/07/10 21:43:35 version 1.279, 2005/07/11 09:49:59
Line 563  EDITBUTTON Line 563  EDITBUTTON
   
 sub end_body {  sub end_body {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = &end_p; # Close off unclosed <p>      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') {
Line 575  sub end_body { Line 575  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 = &end_p; # Close off any prior para.      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 596  sub end_center { Line 596  sub end_center {
 }  }
   
 #-- <b> tag (end tag required)  #-- <b> tag (end tag required)
   #      NOTE: In TeX mode disables internal <p>
 sub start_b {  sub start_b {
     my ($target,$token) = @_;      my ($target,$token) = @_;
     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 = '\textbf{';     &disable_para();
    $currentstring .= '\textbf{';  
     }       } 
     return $currentstring;      return $currentstring;
 }  }
Line 613  sub end_b { Line 615  sub end_b {
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring = $token->[2];        $currentstring = $token->[2];     
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  $currentstring = '}';     &enable_para();
    $currentstring = '}';
     }       } 
     return $currentstring;      return $currentstring;
 }  }
   
 #-- <strong> tag (end tag required)  #-- <strong> tag (end tag required)
   #    NOTE: in TeX mode disables internal <p>
 sub start_strong {  sub start_strong {
     my ($target,$token) = @_;      my ($target,$token) = @_;
     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') {
    &disable_para();
  $currentstring = '\textbf{';     $currentstring = '\textbf{';  
     }       } 
     return $currentstring;      return $currentstring;
Line 636  sub end_strong { Line 641  sub end_strong {
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring = $token->[2];        $currentstring = $token->[2];     
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
    &enable_para();
  $currentstring = '}';     $currentstring = '}';  
     }      }
     return $currentstring;      return $currentstring;
Line 644  sub end_strong { Line 650  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 = &end_p; # Close off any prior para.      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 693  sub end_h1 { Line 699  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 = &end_p; # Close off any prior para.      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 736  sub end_h2 { Line 742  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 = &end_p; # Close off any prior para.      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 779  sub end_h3 { Line 785  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 = &end_p; # Close off any prior para.      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 822  sub end_h4 { Line 828  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 = &end_p; # Close off any prior paras.      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 865  sub end_h5 { Line 871  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 = &end_p; # Close off any prior paras.      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 1123  sub end_q { Line 1129  sub end_q {
   
     my $closing_string = ''; # String required to close <p>      my $closing_string = ''; # String required to close <p>
   
   #   Some tags are <p> fragile meaning that <p> inside of them
   #   does not work within TeX mode.  This is managed via the 
   #   counter below:
   #
   
       my $para_disabled = 0;
   
   sub disable_para {
       $para_disabled++;
   }
   sub enable_para {
       $para_disabled--;
   }
   
   
 #-- <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 = &end_p; # close off prior para if in progress.      my $currentstring = '';
     if ($target eq 'web') {      if ($target eq 'web') {
    $currentstring .= &end_p(); # close off prior para if in progress.
  $currentstring .= $token->[4];   $currentstring .= $token->[4];
  $closing_string = '</p>'; # Not sure this is correct.   if (! ($currentstring =~ /\//)) {
     } elsif ($target eq 'tex') {      $closing_string = '</p>'; # Deal correctly with <p /> e.g.
    }
       } elsif ($target eq 'tex' && !$para_disabled) {
    $currentstring .= &end_p(); # close off prior para if in progress.
  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';
Line 1144  sub start_p { Line 1169  sub start_p {
     $closing_string = '}\hfill}';      $closing_string = '}\hfill}';
  } else {   } else {
             $currentstring.='\par ';              $currentstring.='\par ';
     $closing_string = '\strut\\\\\strut';      $closing_string = '\strut\\\\\strut ';
         }          }
  my $signal=1;#<p> does not work inside <b>...</b>   
  foreach my $tag (@$tagstack) {  
     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;      return $currentstring;
Line 1164  sub start_p { Line 1179  sub start_p {
 #  End paragraph processing just requires that we output the  #  End paragraph processing just requires that we output the
 #  closing string that was saved and blank it.  #  closing string that was saved and blank it.
 sub end_p {  sub end_p {
     my $current_string = $closing_string;      #  Note only 'tex' mode uses disable_para and enable_para
     $closing_string = ''; # Not in a para anymore.      #  so we don't need to know the target in the check below:
     return $current_string;  
       if (!$para_disabled) {
    my $current_string = $closing_string;
    $closing_string = ''; # Not in a para anymore.
    return $current_string;
       } else {
    return '';
       }
   
 }  }
 }  }
Line 1415  sub end_sup { Line 1437  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 = &end_p; # End enclosing para.      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 1455  sub end_hr { Line 1477  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 = &end_p; # Close enclosing para.      my $currentstring = &end_p(); # Close enclosing para.
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring .= $token->[4];   $currentstring .= $token->[4];
     }       } 
Line 1537  sub start_li { Line 1559  sub start_li {
   
 sub end_li {  sub end_li {
     my ($target,$token) = @_;      my ($target,$token) = @_;
     my $currentstring = &end_p; # In case there's a <p> in the <li>      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];     
     }       } 
Line 1573  sub end_u { Line 1595  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 = &end_p; # Close off enclosing list.      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') {
Line 1640  sub end_menu { Line 1662  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 = &end_p; # In case there's a <p> prior to the list.      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') {
Line 1663  sub end_dir { Line 1685  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 = &end_p; # In case there's a <p> prior to the list.      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') {
Line 1717  sub end_ol { Line 1739  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 = &end_p; # In case there's a <p> unclosed prior to the list.      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') {
Line 1833  sub end_dd { Line 1855  sub end_dd {
 sub start_table {  sub start_table {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $textwidth = '';      my $textwidth = '';
     my $currentstring = &end_p;      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') {
Line 2153  sub start_tr { Line 2175  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 = &end_p; # Close any pending <p> in the row.      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') {
Line 2430  sub end_th_tex { Line 2452  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 = &end_p; # Close any open <p> in the row.      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') {
Line 2880  sub end_xmp { Line 2902  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 = &end_p; # close off pending <p>      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 2943  sub end_externallink { Line 2965  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 = &end_p; # closes off any unclosed <p>      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 3096  sub end_blink { Line 3118  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 = &end_p; # Close any unclosed <p>      my $currentstring = &end_p(); # Close any unclosed <p>
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring .= $token->[4];        $currentstring .= $token->[4];     
     }       } 
Line 3419  sub end_marquee { Line 3441  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 = &end_p; # Close any pending <p>      my $currentstring = &end_p(); # Close any pending <p>
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring .= $token->[4];        $currentstring .= $token->[4];     
     }       } 
Line 3617  sub end_server { Line 3639  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 = &end_p; # Close off any open <p> tag.      my $currentstring = &end_p(); # Close off any open <p> tag.
     if ($target eq 'web') {      if ($target eq 'web') {
  $currentstring .= $token->[4];        $currentstring .= $token->[4];     
     }       } 

Removed from v.1.278  
changed lines
  Added in v.1.279


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