Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style Highlight Question #97

Open
g-pearl opened this issue Apr 5, 2020 · 2 comments
Open

Style Highlight Question #97

g-pearl opened this issue Apr 5, 2020 · 2 comments

Comments

@g-pearl
Copy link

g-pearl commented Apr 5, 2020

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
Copy link
Owner

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants