Commit f74e5b79 authored by Fred Drake's avatar Fred Drake

Control the layout of output tables a little better so they're easier

to debug.  Small code cleanup around tables.
parent cf282cda
...@@ -159,7 +159,9 @@ sub do_cmd_dfn{ ...@@ -159,7 +159,9 @@ sub do_cmd_dfn{
sub do_cmd_emph{ sub do_cmd_emph{
return use_italics(@_); } return use_italics(@_); }
sub do_cmd_file{ sub do_cmd_file{
return use_wrappers(@_[0], '"<tt class=file>', '</tt>"'); } return use_wrappers(@_[0], '<tt class=file>', '</tt>'); }
sub do_cmd_filenq{
return use_wrappers(@_[0], '<tt class=file>', '</tt>'); }
sub do_cmd_samp{ sub do_cmd_samp{
return use_wrappers(@_[0], '"<tt class=samp>', '</tt>"'); } return use_wrappers(@_[0], '"<tt class=samp>', '</tt>"'); }
sub do_cmd_kbd{ sub do_cmd_kbd{
...@@ -789,6 +791,19 @@ sub get_th{ ...@@ -789,6 +791,19 @@ sub get_th{
return $r; return $r;
} }
sub fix_font{
# do a little magic on a font name to get the right behavior in the first
# column of the output table
my $font = @_[0];
if ($font eq 'textrm') {
$font = '';
}
elsif ($font eq 'file' || $font eq 'filenq') {
$font = 'tt class=file';
}
return $font;
}
sub setup_column_alignments{ sub setup_column_alignments{
local($_) = @_; local($_) = @_;
my($a1,$a2,$a3,$a4) = split(/[|]/,$_); my($a1,$a2,$a3,$a4) = split(/[|]/,$_);
...@@ -804,33 +819,36 @@ sub setup_column_alignments{ ...@@ -804,33 +819,36 @@ sub setup_column_alignments{
sub do_env_tableii{ sub do_env_tableii{
local($_) = @_; local($_) = @_;
my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument()); my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
my $font = next_argument(); my $font = fix_font(next_argument());
my $h1 = next_argument(); my $h1 = next_argument();
my $h2 = next_argument(); my $h2 = next_argument();
$font = '' s/[\s\n]+//;
if ($font eq 'textrm');
$globals{'lineifont'} = $font; $globals{'lineifont'} = $font;
return '<table border align=center><thead>' return '<table border align=center>'
. "\n <thead>"
. "\n <tr$TABLE_HEADER_BGCOLOR>" . "\n <tr$TABLE_HEADER_BGCOLOR>"
. "\n $th1<b>$h1</b></th>" . "\n $th1<b>$h1</b></th>"
. "\n $th2<b>$h2</b></th>" . "\n $th2<b>$h2</b></th>"
. "\n</thead>" . "\n </thead>"
. "\n<tbody valign=baseline>" . "\n <tbody valign=baseline>"
. $_ . $_
. "\n</tbody></table>"; . "\n </tbody>"
. "\n</table>";
} }
sub do_cmd_lineii{ sub do_cmd_lineii{
local($_) = @_; local($_) = @_;
my $c1 = next_argument(); my $c1 = next_argument();
my $c2 = next_argument(); my $c2 = next_argument();
s/[\s\n]+//;
my($font,$sfont,$efont) = ($globals{'lineifont'}, '', ''); my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
if ($font) { if ($font) {
$sfont = "<$font>"; $sfont = "<$font>";
$efont = "</$font>"; $efont = "</$font>";
$efont =~ s/ .*>/>/;
} }
my($c1align,$c2align) = @col_aligns[0,1]; my($c1align,$c2align) = @col_aligns[0,1];
return "<tr>$c1align$sfont$c1$efont</td>\n" return "\n <tr>$c1align$sfont$c1$efont</td>\n"
. " $c2align$c2\&nbsp;</td>" . " $c2align$c2\&nbsp;</td>"
. $_; . $_;
} }
...@@ -838,22 +856,23 @@ sub do_cmd_lineii{ ...@@ -838,22 +856,23 @@ sub do_cmd_lineii{
sub do_env_tableiii{ sub do_env_tableiii{
local($_) = @_; local($_) = @_;
my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument()); my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
my $font = next_argument(); my $font = fix_font(next_argument());
my $h1 = next_argument(); my $h1 = next_argument();
my $h2 = next_argument(); my $h2 = next_argument();
my $h3 = next_argument(); my $h3 = next_argument();
$font = '' s/[\s\n]+//;
if ($font eq 'textrm');
$globals{'lineifont'} = $font; $globals{'lineifont'} = $font;
return '<table border align=center><thead>' return '<table border align=center>'
. "\n <thead>"
. "\n <tr$TABLE_HEADER_BGCOLOR>" . "\n <tr$TABLE_HEADER_BGCOLOR>"
. "\n $th1<b>$h1</b></th>" . "\n $th1<b>$h1</b></th>"
. "\n $th2<b>$h2</b></th>" . "\n $th2<b>$h2</b></th>"
. "\n $th3<b>$h3</b></th>" . "\n $th3<b>$h3</b></th>"
. "\n</thead>" . "\n </thead>"
. "\n<tbody valign=baseline>" . "\n <tbody valign=baseline>"
. $_ . $_
. "\n</tbody></table>"; . "\n </tbody>"
. "\n</table>";
} }
sub do_cmd_lineiii{ sub do_cmd_lineiii{
...@@ -861,13 +880,15 @@ sub do_cmd_lineiii{ ...@@ -861,13 +880,15 @@ sub do_cmd_lineiii{
my $c1 = next_argument(); my $c1 = next_argument();
my $c2 = next_argument(); my $c2 = next_argument();
my $c3 = next_argument(); my $c3 = next_argument();
s/[\s\n]+//;
my($font,$sfont,$efont) = ($globals{'lineifont'}, '', ''); my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
if ($font) { if ($font) {
$sfont = "<$font>"; $sfont = "<$font>";
$efont = "</$font>"; $efont = "</$font>";
$efont =~ s/ .*>/>/;
} }
my($c1align,$c2align,$c3align) = @col_aligns[0,1,2]; my($c1align,$c2align,$c3align) = @col_aligns[0,1,2];
return "<tr>$c1align$sfont$c1$efont</td>\n" return "\n <tr>$c1align$sfont$c1$efont</td>\n"
. " $c2align$c2</td>\n" . " $c2align$c2</td>\n"
. " $c3align$c3\&nbsp;</td>" . " $c3align$c3\&nbsp;</td>"
. $_; . $_;
...@@ -876,24 +897,25 @@ sub do_cmd_lineiii{ ...@@ -876,24 +897,25 @@ sub do_cmd_lineiii{
sub do_env_tableiv{ sub do_env_tableiv{
local($_) = @_; local($_) = @_;
my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument()); my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
my $font = next_argument(); my $font = fix_font(next_argument());
my $h1 = next_argument(); my $h1 = next_argument();
my $h2 = next_argument(); my $h2 = next_argument();
my $h3 = next_argument(); my $h3 = next_argument();
my $h4 = next_argument(); my $h4 = next_argument();
$font = '' s/[\s\n]+//;
if ($font eq 'textrm');
$globals{'lineifont'} = $font; $globals{'lineifont'} = $font;
return '<table border align=center><thead>' return '<table border align=center>'
. "\n <thead>"
. "\n <tr$TABLE_HEADER_BGCOLOR>" . "\n <tr$TABLE_HEADER_BGCOLOR>"
. "\n $th1<b>$h1</b></th>" . "\n $th1<b>$h1</b></th>"
. "\n $th2<b>$h2</b></th>" . "\n $th2<b>$h2</b></th>"
. "\n $th3<b>$h3</b></th>" . "\n $th3<b>$h3</b></th>"
. "\n $th4<b>$h4</b></th>" . "\n $th4<b>$h4</b></th>"
. "\n</thead>" . "\n </thead>"
. "\n<tbody valign=baseline>" . "\n <tbody valign=baseline>"
. $_ . $_
. "\n</tbody></table>"; . "\n </tbody>"
. "\n</table>";
} }
sub do_cmd_lineiv{ sub do_cmd_lineiv{
...@@ -902,13 +924,15 @@ sub do_cmd_lineiv{ ...@@ -902,13 +924,15 @@ sub do_cmd_lineiv{
my $c2 = next_argument(); my $c2 = next_argument();
my $c3 = next_argument(); my $c3 = next_argument();
my $c4 = next_argument(); my $c4 = next_argument();
s/[\s\n]+//;
my($font,$sfont,$efont) = ($globals{'lineifont'}, '', ''); my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
if ($font) { if ($font) {
$sfont = "<$font>"; $sfont = "<$font>";
$efont = "</$font>"; $efont = "</$font>";
$efont =~ s/ .*>/>/;
} }
my($c1align,$c2align,$c3align,$c4align) = @col_aligns; my($c1align,$c2align,$c3align,$c4align) = @col_aligns;
return "<tr>$c1align$sfont$c1$efont</td>\n" return "\n <tr>$c1align$sfont$c1$efont</td>\n"
. " $c2align$c2</td>\n" . " $c2align$c2</td>\n"
. " $c3align$c3</td>\n" . " $c3align$c3</td>\n"
. " $c4align$c4\&nbsp;</td>" . " $c4align$c4\&nbsp;</td>"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment