iainbrighton / PScribo

PowerShell documentation framework
MIT License
230 stars 35 forks source link

Style Highlight Question #97

Open g-pearl opened 4 years ago

g-pearl commented 4 years ago

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 4 years ago

Hi @g-pearl, I think you're after the implementation outlined in #75? This would permit you to apply a different style to a particular "Run" within a paragraph.

iainbrighton commented 4 years ago

@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.