You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-17 01:12:23 +02:00
Add table render for Markdown format.
Contributed by Cynthia Shang.
This commit is contained in:
committed by
David Steele
parent
ca52a0485e
commit
0e27060952
@ -302,7 +302,7 @@ sub sectionProcess
|
|||||||
# Add descriptive text
|
# Add descriptive text
|
||||||
elsif ($oChild->nameGet() eq 'p')
|
elsif ($oChild->nameGet() eq 'p')
|
||||||
{
|
{
|
||||||
if (defined($strLastChild) && $strLastChild ne 'code-block')
|
if (defined($strLastChild) && $strLastChild ne 'code-block' && $strLastChild ne 'table')
|
||||||
{
|
{
|
||||||
$strMarkdown .= "\n";
|
$strMarkdown .= "\n";
|
||||||
}
|
}
|
||||||
@ -357,7 +357,60 @@ sub sectionProcess
|
|||||||
{
|
{
|
||||||
$strMarkdown = trim($strMarkdown) . "\n\n" . $self->sectionProcess($oChild, $iDepth + 1);
|
$strMarkdown = trim($strMarkdown) . "\n\n" . $self->sectionProcess($oChild, $iDepth + 1);
|
||||||
}
|
}
|
||||||
# Check if the child can be processed by a parent
|
elsif ($oChild->nameGet() eq 'table')
|
||||||
|
{
|
||||||
|
my $oTableTitle;
|
||||||
|
if ($oChild->nodeTest('title'))
|
||||||
|
{
|
||||||
|
$oTableTitle = $oChild->nodeGet('title');
|
||||||
|
}
|
||||||
|
|
||||||
|
my $oHeader = $oChild->nodeGet('table-header');
|
||||||
|
my @oyColumn = $oHeader->nodeList('table-column');
|
||||||
|
if (defined($oTableTitle))
|
||||||
|
{
|
||||||
|
# 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())) :
|
||||||
|
$self->processText($oTableTitle->textGet())) . "**\n\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$strMarkdown .= "\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
my ($strHeaderText, $strHeaderIndicator);
|
||||||
|
|
||||||
|
for (my $iColCellIdx = 0; $iColCellIdx < @oyColumn; $iColCellIdx++)
|
||||||
|
{
|
||||||
|
my $strAlign = $oyColumn[$iColCellIdx]->paramGet("align", false, 'left');
|
||||||
|
|
||||||
|
$strHeaderText .= $self->processText($oyColumn[$iColCellIdx]->textGet()) .
|
||||||
|
(($iColCellIdx < @oyColumn - 1) ? " | " : "\n");
|
||||||
|
$strHeaderIndicator .= ($strAlign eq 'left' || $strAlign eq 'center') ? ":---" : "---";
|
||||||
|
$strHeaderIndicator .= ($strAlign eq 'right' || $strAlign eq 'center') ? "---:" : "";
|
||||||
|
$strHeaderIndicator .= ($iColCellIdx < @oyColumn - 1) ? " | " : "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$strMarkdown .= $strHeaderText .$strHeaderIndicator;
|
||||||
|
|
||||||
|
# Build the rows
|
||||||
|
foreach my $oRow ($oChild->nodeGet('table-data')->nodeList('table-row'))
|
||||||
|
{
|
||||||
|
my @oRowCellList = $oRow->nodeList('table-cell');
|
||||||
|
|
||||||
|
for (my $iRowCellIdx = 0; $iRowCellIdx < @oRowCellList; $iRowCellIdx++)
|
||||||
|
{
|
||||||
|
my $oRowCell = $oRowCellList[$iRowCellIdx];
|
||||||
|
|
||||||
|
$strMarkdown .= $self->processText($oRowCell->textGet()) .
|
||||||
|
(($iRowCellIdx < @oRowCellList -1) ? " | " : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
$strMarkdown .= "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# Check if the child can be processed by a parent
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
# $self->sectionChildProcess($oSection, $oChild, $iDepth + 1);
|
# $self->sectionChildProcess($oSection, $oChild, $iDepth + 1);
|
||||||
|
@ -153,6 +153,14 @@
|
|||||||
<p>Allow code blocks to have a type. Currently this is only rendered in Markdown.</p>
|
<p>Allow code blocks to have a type. Currently this is only rendered in Markdown.</p>
|
||||||
</release-item>
|
</release-item>
|
||||||
|
|
||||||
|
<release-item>
|
||||||
|
<release-item-contributor-list>
|
||||||
|
<release-item-contributor id="shang.cynthia"/>
|
||||||
|
</release-item-contributor-list>
|
||||||
|
|
||||||
|
<p>Add table render for Markdown format.</p>
|
||||||
|
</release-item>
|
||||||
|
|
||||||
<release-item>
|
<release-item>
|
||||||
<p>Deploy historical documentation to <path>prior</path> rather than the root directory.</p>
|
<p>Deploy historical documentation to <path>prior</path> rather than the root directory.</p>
|
||||||
</release-item>
|
</release-item>
|
||||||
|
Reference in New Issue
Block a user