[Python-checkins] CVS: python/dist/src/Doc/perl python.perl,1.65.2.3,1.65.2.4

Fred L. Drake fdrake@weyr.cnri.reston.va.us
Wed, 16 Feb 2000 12:14:01 -0500 (EST)


Update of /projects/cvsroot/python/dist/src/Doc/perl
In directory weyr:/home/fdrake/projects/python/Doc-152p1/perl

Modified Files:
      Tag: release152p1-patches
	python.perl 
Log Message:

Work over the table support a little; this gets the 'r' column
specifier right (previously not properly handled for data cells in
tables, header cells were fine).

get_th():  Removed.

figure_column_alignment():  New function; converts a latex table
        column specifier to the appropriate 'align="foo"' value
        suitable for use in <th> and <td> start tags.  (get_th() was
        specific to <th>.)

setup_column_alignments():  Adjusted to use figure_column_alignment()
        instead of get_th().

do_cmd_lineii(),
do_cmd_lineiii(),
do_cmd_lineiv():  If the first cell is right-aligned, add a trailing
        non-breaking space for padding.  This improves readability
        when the first column is right-aligned and the second column
        is left-aligned.

do_env_tableii(),
do_env_tableiii(),
do_env_tableiv():  But don't overdo the first-column padding in the
        header cells.


Index: python.perl
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Doc/perl/python.perl,v
retrieving revision 1.65.2.3
retrieving revision 1.65.2.4
diff -C2 -r1.65.2.3 -r1.65.2.4
*** python.perl	2000/02/01 19:06:40	1.65.2.3
--- python.perl	2000/02/16 17:13:58	1.65.2.4
***************
*** 869,886 ****
  $TABLE_HEADER_BGCOLOR = $NAV_BGCOLOR;
  
- sub get_th{
-     my $a = @_[0];
-     my $r = '<th>';
-     if ($a eq 'l')
-       { $r = '<th align="left">'; }
-     elsif (substr($a, 0, 1) eq 'p')
-       { $r = '<th align="left">'; }
-     elsif ($a eq 'r')
-       { $r = '<th align="right">'; }
-     elsif ($a eq 'c')
-       { $r = '<th align="center">'; }
-     return $r;
- }
- 
  sub fix_font{
      # do a little magic on a font name to get the right behavior in the first
--- 869,872 ----
***************
*** 899,913 ****
  }
  
  sub setup_column_alignments{
      local($_) = @_;
!     my($a1,$a2,$a3,$a4) = split(/[|]/,$_);
!     my($th1,$th2,$th3,$th4) = ('<th>', '<th>', '<th>', '<th>');
!     $col_aligns[0] = (($a1 eq 'c') ? '<td align="center" valign="baseline">'
! 		                   : '<td valign="baseline">');
!     $col_aligns[1] = (($a2 eq 'c') ? '<td align="center">' : '<td>');
!     $col_aligns[2] = (($a3 eq 'c') ? '<td align="center">' : '<td>');
!     $col_aligns[3] = (($a4 eq 'c') ? '<td align="center">' : '<td>');
      # return the aligned header start tags
!     return (get_th($a1), get_th($a2), get_th($a3), get_th($a4));
  }
  
--- 885,916 ----
  }
  
+ sub figure_column_alignment{
+     my $a = @_[0];
+     my $mark = substr($a, 0, 1);
+     my $r = '';
+     if ($mark eq 'c')
+       { $r = ' align="center"'; }
+     elsif ($mark eq 'r')
+       { $r = ' align="right" '; }
+     elsif ($mark eq 'l')
+       { $r = ' align="left"  '; }
+     elsif ($mark eq 'p')
+       { $r = ' align="left"  '; }
+     return $r;
+ }
+ 
  sub setup_column_alignments{
      local($_) = @_;
!     my($s1,$s2,$s3,$s4) = split(/[|]/,$_);
!     my $a1 = figure_column_alignment($s1);
!     my $a2 = figure_column_alignment($s2);
!     my $a3 = figure_column_alignment($s3);
!     my $a4 = figure_column_alignment($s4);
!     $col_aligns[0] = "<td$a1 valign=\"baseline\">";
!     $col_aligns[1] = "<td$a2>";
!     $col_aligns[2] = "<td$a3>";
!     $col_aligns[3] = "<td$a4>";
      # return the aligned header start tags
!     return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>");
  }
  
***************
*** 934,939 ****
             . "\n  <thead>"
             . "\n    <tr$TABLE_HEADER_BGCOLOR>"
! 	   . "\n      $th1<b>$h1</b>\&nbsp;\&nbsp;</th>"
! 	   . "\n      $th2<b>$h2</b>\&nbsp;\&nbsp;</th>"
  	   . "\n    </thead>"
  	   . "\n  <tbody valign='baseline'>"
--- 937,942 ----
             . "\n  <thead>"
             . "\n    <tr$TABLE_HEADER_BGCOLOR>"
! 	   . "\n      $th1<b>$h1</b>\&nbsp;</th>"
! 	   . "\n      $th2<b>$h2</b>\&nbsp;</th>"
  	   . "\n    </thead>"
  	   . "\n  <tbody valign='baseline'>"
***************
*** 951,955 ****
      $c2 = '&nbsp;' if ($c2 eq '');
      my($c1align,$c2align) = @col_aligns[0,1];
!     return "\n    <tr>$c1align$sfont$c1$efont</td>\n"
             . "        $c2align$c2</td>"
  	   . $_;
--- 954,962 ----
      $c2 = '&nbsp;' if ($c2 eq '');
      my($c1align,$c2align) = @col_aligns[0,1];
!     my $padding = '';
!     if ($c1align =~ /align="right"/) {
!         $padding = '&nbsp;';
!     }
!     return "\n    <tr>$c1align$sfont$c1$efont$padding</td>\n"
             . "        $c2align$c2</td>"
  	   . $_;
***************
*** 968,974 ****
             . "\n  <thead>"
             . "\n    <tr$TABLE_HEADER_BGCOLOR>"
! 	   . "\n      $th1<b>$h1</b>\&nbsp;\&nbsp;</th>"
! 	   . "\n      $th2<b>$h2</b>\&nbsp;\&nbsp;</th>"
! 	   . "\n      $th3<b>$h3</b>\&nbsp;\&nbsp;</th>"
  	   . "\n    </thead>"
  	   . "\n  <tbody valign='baseline'>"
--- 975,981 ----
             . "\n  <thead>"
             . "\n    <tr$TABLE_HEADER_BGCOLOR>"
! 	   . "\n      $th1<b>$h1</b>\&nbsp;</th>"
! 	   . "\n      $th2<b>$h2</b>\&nbsp;</th>"
! 	   . "\n      $th3<b>$h3</b>\&nbsp;</th>"
  	   . "\n    </thead>"
  	   . "\n  <tbody valign='baseline'>"
***************
*** 987,991 ****
      $c3 = '&nbsp;' if ($c3 eq '');
      my($c1align,$c2align,$c3align) = @col_aligns[0,1,2];
!     return "\n    <tr>$c1align$sfont$c1$efont</td>\n"
             . "        $c2align$c2</td>\n"
  	   . "        $c3align$c3</td>"
--- 994,1002 ----
      $c3 = '&nbsp;' if ($c3 eq '');
      my($c1align,$c2align,$c3align) = @col_aligns[0,1,2];
!     my $padding = '';
!     if ($c1align =~ /align="right"/) {
!         $padding = '&nbsp;';
!     }
!     return "\n    <tr>$c1align$sfont$c1$efont$padding</td>\n"
             . "        $c2align$c2</td>\n"
  	   . "        $c3align$c3</td>"
***************
*** 1006,1013 ****
             . "\n  <thead>"
             . "\n    <tr$TABLE_HEADER_BGCOLOR>"
! 	   . "\n      $th1<b>$h1</b>\&nbsp;\&nbsp;</th>"
! 	   . "\n      $th2<b>$h2</b>\&nbsp;\&nbsp;</th>"
! 	   . "\n      $th3<b>$h3</b>\&nbsp;\&nbsp;</th>"
! 	   . "\n      $th4<b>$h4</b>\&nbsp;\&nbsp;</th>"
  	   . "\n    </thead>"
  	   . "\n  <tbody valign='baseline'>"
--- 1017,1024 ----
             . "\n  <thead>"
             . "\n    <tr$TABLE_HEADER_BGCOLOR>"
! 	   . "\n      $th1<b>$h1</b>\&nbsp;</th>"
! 	   . "\n      $th2<b>$h2</b>\&nbsp;</th>"
! 	   . "\n      $th3<b>$h3</b>\&nbsp;</th>"
! 	   . "\n      $th4<b>$h4</b>\&nbsp;</th>"
  	   . "\n    </thead>"
  	   . "\n  <tbody valign='baseline'>"
***************
*** 1027,1031 ****
      $c4 = '&nbsp;' if ($c4 eq '');
      my($c1align,$c2align,$c3align,$c4align) = @col_aligns;
!     return "\n    <tr>$c1align$sfont$c1$efont</td>\n"
             . "        $c2align$c2</td>\n"
  	   . "        $c3align$c3</td>\n"
--- 1038,1046 ----
      $c4 = '&nbsp;' if ($c4 eq '');
      my($c1align,$c2align,$c3align,$c4align) = @col_aligns;
!     my $padding = '';
!     if ($c1align =~ /align="right"/) {
!         $padding = '&nbsp;';
!     }
!     return "\n    <tr>$c1align$sfont$c1$efont$padding</td>\n"
             . "        $c2align$c2</td>\n"
  	   . "        $c3align$c3</td>\n"