1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-14 10:13:05 +02:00

Add optional table captions.

All renderers now support table captions, when requested.

Contributed by Cynthia Shang.
This commit is contained in:
Cynthia Shang 2018-12-20 23:20:54 +02:00 committed by David Steele
parent 8cf8d29f12
commit 3dc327fd05
7 changed files with 37 additions and 11 deletions

View File

@ -28,6 +28,8 @@ use constant HTML_SPAN => 'span';
push @EXPORT, qw(HTML_SPAN);
use constant HTML_TABLE => 'table';
push @EXPORT, qw(HTML_TABLE);
use constant HTML_TABLE_CAPTION => 'caption';
push @EXPORT, qw(HTML_TABLE_CAPTION);
use constant HTML_TD => 'td';
push @EXPORT, qw(HTML_TD);
use constant HTML_TH => 'th';

View File

@ -406,6 +406,17 @@ sub sectionProcess
my $oTableElement = $oSectionBodyElement->addNew(HTML_TABLE, 'table');
my @oyColumn;
# If there is a title element then add it as the caption for the table
if (defined($oTableTitle))
{
# Print the label (e.g. Table 1:) in front of the title if one exists
my $strTableTitle = $oTableTitle->paramTest('label') ?
($oTableTitle->paramGet('label') . ': '. $self->processText($oTableTitle->textGet())) :
$self->processText($oTableTitle->textGet());
$oTableElement->addNew(HTML_TABLE_CAPTION, 'table-caption', {strContent => $strTableTitle});
}
# Build the header
if ($oChild->nodeTest('table-header'))
{

View File

@ -241,11 +241,10 @@ sub sectionProcess
'{' . (defined($oHeader) && $oHeader->paramTest('width') ? ($oHeader->paramGet('width') / 100) .
'\textwidth' : '\textwidth') . '}';
# Build the table
$strLatex .= "\\vspace{1em}\\newline\n\\begin{table}\n\\begin{tabularx}${strWidth}{|";
# Build the table header
$strLatex .= "\\vspace{1em}\\newline\n";
$strLatex .= "\\begin{tabularx}${strWidth}{|";
foreach my $oColumn (@oyColumn)
{
my $strAlignCode;
@ -307,11 +306,6 @@ sub sectionProcess
$strLatex .= "}\n";
if ($oChild->nodeGet("title", false))
{
$strLatex .= "\\caption{" . $self->processText($oChild->nodeGet("title")->textGet()) . ":}\\\\\n";
}
my $strLine;
if (defined($oHeader))
@ -342,6 +336,15 @@ sub sectionProcess
}
$strLatex .= "\\hline\n\\end{tabularx}\n";
# If there is a title for the table, add it. Ignore the label since LaTex will automatically generate numbered labels.
# e.g. Table 1:
if ($oChild->nodeGet("title", false))
{
$strLatex .= "\\caption{" . $self->processText($oChild->nodeGet("title")->textGet()) . "}\n";
}
$strLatex .= "\\end{table}\n";
}
# Add descriptive text
elsif ($oChild->nameGet() eq 'p')

View File

@ -378,7 +378,7 @@ sub sectionProcess
{
# Print the label (e.g. Table 1:) in front of the title if one exists
$strMarkdown .= "\n\n**" . ($oTableTitle->paramTest('label') ?
($oTableTitle->paramGet('label') . $self->processText($oTableTitle->textGet())) :
($oTableTitle->paramGet('label') . ': ' . $self->processText($oTableTitle->textGet())) :
$self->processText($oTableTitle->textGet())) . "**\n\n";
}
else

View File

@ -303,6 +303,15 @@ Table Elements
*******************************************************************************/
.table
{
margin-top: .5em;
}
.table-caption
{
text-align: left;
font-size: 12pt;
font-weight: bold;
color: #396a93;
}
.table-header-row

View File

@ -207,6 +207,7 @@
<!-- Table elements -->
<!ELEMENT table (title?, table-header?, table-data)>
<!ATTLIST title label CDATA "">
<!ELEMENT table-header (table-column+)>
<!ATTLIST table-header width CDATA "">

View File

@ -248,7 +248,7 @@
<release-item-contributor id="cynthia.shang"/>
</release-item-contributor-list>
<p>Add HTML table rendering and update PDF/Markdown renderers to support header-less tables.</p>
<p>Add HTML table rendering and update PDF/Markdown renderers to support header-less tables. Add optional table captions.</p>
</release-item>
<release-item>