You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-12-13 23:25:51 +02:00
Add markdown renderer for execute-list block.
This commit is contained in:
@@ -197,85 +197,81 @@ sub sectionProcess
|
|||||||
# Execute a command
|
# Execute a command
|
||||||
if ($oChild->nameGet() eq 'execute-list')
|
if ($oChild->nameGet() eq 'execute-list')
|
||||||
{
|
{
|
||||||
# my $oSectionBodyExecute = $oSectionBodyElement->addNew(HTML_DIV, "execute");
|
my $bShow = $oChild->paramTest('show', 'n') ? false : true;
|
||||||
# my $bFirst = true;
|
my $bFirst = true;
|
||||||
# my $strHostName = $self->{oManifest}->variableReplace($oChild->paramGet('host'));
|
my $strHostName = $self->{oManifest}->variableReplace($oChild->paramGet('host'));
|
||||||
#
|
my $bOutput = false;
|
||||||
# $oSectionBodyExecute->
|
|
||||||
# addNew(HTML_DIV, "execute-title",
|
if ($bShow)
|
||||||
# {strContent => "<span class=\"host\">${strHostName}</span> <b>⇒</b> " .
|
{
|
||||||
# $self->processText($oChild->nodeGet('title')->textGet())});
|
$strMarkdown .=
|
||||||
#
|
"\n\n${strHostName} => " . $self->processText($oChild->nodeGet('title')->textGet()) .
|
||||||
# my $oExecuteBodyElement = $oSectionBodyExecute->addNew(HTML_DIV, "execute-body");
|
"\n```\n";
|
||||||
#
|
}
|
||||||
# foreach my $oExecute ($oChild->nodeList('execute'))
|
|
||||||
# {
|
foreach my $oExecute ($oChild->nodeList('execute'))
|
||||||
# my $bExeShow = !$oExecute->paramTest('show', 'n');
|
{
|
||||||
# my $bExeExpectedError = defined($oExecute->paramGet('err-expect', false));
|
my $bExeShow = !$oExecute->paramTest('show', 'n');
|
||||||
#
|
my $bExeExpectedError = defined($oExecute->paramGet('err-expect', false));
|
||||||
# my ($strCommand, $strOutput) = $self->execute($oSection, $strHostName, $oExecute, $iDepth + 3);
|
|
||||||
#
|
if ($bOutput)
|
||||||
# if ($bExeShow)
|
{
|
||||||
# {
|
confess &log(ERROR, "only the last command can have output");
|
||||||
# # Add continuation chars and proper spacing
|
}
|
||||||
# $strCommand =~ s/\n/\n /smg;
|
|
||||||
#
|
my ($strCommand, $strOutput) = $self->execute(
|
||||||
# $oExecuteBodyElement->
|
$oSection, $strHostName, $oExecute, {iIndent => $iDepth + 3, bShow => $bShow && $bExeShow});
|
||||||
# addNew(HTML_PRE, "execute-body-cmd",
|
|
||||||
# {strContent => $strCommand, bPre => true});
|
if ($bShow && $bExeShow)
|
||||||
#
|
{
|
||||||
# my $strHighLight = $self->{oManifest}->variableReplace($oExecute->fieldGet('exe-highlight', false));
|
# Add continuation chars and proper spacing
|
||||||
# my $bHighLightFound = false;
|
$strCommand =~ s/\n/\n /smg;
|
||||||
#
|
|
||||||
# if (defined($strOutput))
|
$strMarkdown .= "${strCommand}\n";
|
||||||
# {
|
|
||||||
# my $bHighLightOld;
|
my $strHighLight = $self->{oManifest}->variableReplace($oExecute->fieldGet('exe-highlight', false));
|
||||||
# my $strHighLightOutput;
|
my $bHighLightFound = false;
|
||||||
#
|
|
||||||
# if ($oExecute->fieldTest('exe-highlight-type', 'error'))
|
if (defined($strOutput))
|
||||||
# {
|
{
|
||||||
# $bExeExpectedError = true;
|
$strMarkdown .= "\n--- output ---\n\n";
|
||||||
# }
|
|
||||||
#
|
if ($oExecute->fieldTest('exe-highlight-type', 'error'))
|
||||||
# foreach my $strLine (split("\n", $strOutput))
|
{
|
||||||
# {
|
$bExeExpectedError = true;
|
||||||
# my $bHighLight = defined($strHighLight) && $strLine =~ /$strHighLight/;
|
}
|
||||||
#
|
|
||||||
# if (defined($bHighLightOld) && $bHighLight != $bHighLightOld)
|
foreach my $strLine (split("\n", $strOutput))
|
||||||
# {
|
{
|
||||||
# $oExecuteBodyElement->
|
my $bHighLight = defined($strHighLight) && $strLine =~ /$strHighLight/;
|
||||||
# addNew(HTML_PRE, 'execute-body-output' .
|
|
||||||
# ($bHighLightOld ? '-highlight' . ($bExeExpectedError ? '-error' : '') : ''),
|
if ($bHighLight)
|
||||||
# {strContent => $strHighLightOutput, bPre => true});
|
{
|
||||||
#
|
$strMarkdown .= $bExeExpectedError ? "ERR" : "-->";
|
||||||
# undef($strHighLightOutput);
|
}
|
||||||
# }
|
else
|
||||||
#
|
{
|
||||||
# $strHighLightOutput .= (defined($strHighLightOutput) ? "\n" : '') . $strLine;
|
$strMarkdown .= " ";
|
||||||
# $bHighLightOld = $bHighLight;
|
}
|
||||||
#
|
|
||||||
# $bHighLightFound = $bHighLightFound ? true : $bHighLight ? true : false;
|
$strMarkdown .= " ${strLine}\n";
|
||||||
# }
|
|
||||||
#
|
$bHighLightFound = $bHighLightFound ? true : $bHighLight ? true : false;
|
||||||
# if (defined($bHighLightOld))
|
}
|
||||||
# {
|
|
||||||
# $oExecuteBodyElement->
|
$bFirst = true;
|
||||||
# addNew(HTML_PRE, 'execute-body-output' .
|
}
|
||||||
# ($bHighLightOld ? '-highlight' . ($bExeExpectedError ? '-error' : '') : ''),
|
|
||||||
# {strContent => $strHighLightOutput, bPre => true});
|
if ($self->{bExe} && $self->isRequired($oSection) && defined($strHighLight) && !$bHighLightFound)
|
||||||
# }
|
{
|
||||||
#
|
confess &log(ERROR, "unable to find a match for highlight: ${strHighLight}");
|
||||||
# $bFirst = true;
|
}
|
||||||
# }
|
}
|
||||||
#
|
|
||||||
# if ($self->{bExe} && $self->isRequired($oSection) && defined($strHighLight) && !$bHighLightFound)
|
$bFirst = false;
|
||||||
# {
|
}
|
||||||
# confess &log(ERROR, "unable to find a match for highlight: ${strHighLight}");
|
|
||||||
# }
|
$strMarkdown .= "```";
|
||||||
# }
|
|
||||||
#
|
|
||||||
# $bFirst = false;
|
|
||||||
# }
|
|
||||||
}
|
}
|
||||||
# Add code block
|
# Add code block
|
||||||
elsif ($oChild->nameGet() eq 'code-block')
|
elsif ($oChild->nameGet() eq 'code-block')
|
||||||
@@ -439,7 +435,7 @@ sub sectionProcess
|
|||||||
# Check if the child can be processed by a parent
|
# Check if the child can be processed by a parent
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
# $self->sectionChildProcess($oSection, $oChild, $iDepth + 1);
|
$self->sectionChildProcess($oSection, $oChild, $iDepth + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$strLastChild = $oChild->nameGet();
|
$strLastChild = $oChild->nameGet();
|
||||||
|
|||||||
Reference in New Issue
Block a user