Style Highlight Question
Opened this issue · 2 comments
g-pearl commented
I am trying to work on a configuration report and I want to Highlight areas that are incorrect.
I have everything working like I want but when I apply a style it highlights the entire line but I would like it to highlight only the provided text.
Is there a WholeLine (True/False) parameter that I missed or is this the designed result. I could see both options being useful.
Code is as follows:
Import-Module PScribo
Document 'PScribo Example' {
Style -Name 'Error' -Color White -BackgroundColor Firebrick -Bold
$mailgood = "mailhub=10.10.10.20"
$mailbad = "mailhub=localhost"
$OverrideGood = "FromLineOverride=YES"
$Overridebad = "FromLineOverride=NO"
$DNSGood = "8.8.8.8"
$DNSBad = $null
if ($mailgood -like "*hub=10.10*")
{
Paragraph -Style normal $mailgood
}
else
{
Paragraph -Style Error $mailgood
}
if ($mailbad -like "*hub=10.10*")
{
Paragraph -Style normal $mailbad
}
else
{
Paragraph -Style Error $mailbad
}
if (![string]::IsNullOrWhiteSpace($DNSGood))
{
Paragraph -Style normal $DNSGood
}
else
{
Paragraph -Style Error $DNSGood
}
if (![string]::IsNullOrWhiteSpace($DNSBad))
{
Paragraph -Style normal $DNSBad
}
else
{
Paragraph -Style Error "DNS Undefined"
}
} | Export-Document -Path ~\Desktop -Format Word -Verbose
iainbrighton commented
iainbrighton commented
@g-pearl This functionality is now available in the dev branch if you want to take it for a spin. You will need to use the new Paragraph { }
implementation for it to work (the old implementation will remain for compatibility and ease of use). See Example38.ps1
for more details.