EvotecIT / PSWriteHTML

PSWriteHTML is PowerShell Module to generate beautiful HTML reports, pages, emails without any knowledge of HTML, CSS or JavaScript. To get started basics PowerShell knowledge is required.
MIT License
826 stars 106 forks source link

line breaks in tables #273

Closed raymix closed 3 years ago

raymix commented 3 years ago

Hi

I'm trying to include line breaks in table cells () to make them multi-line. I've tried adding
,


,

tags, but they just end up being rendered as text.

Using "n" and "r" kinda works when inspecting table using browser developer tools - I can see that both text and html code is breaking my text correctly, but it is still being rendered in one long line in table.

I have tried adding -Wordbreak to Table and-NewLine to TableOption cmdlets, but they had no effect.

Thanks

PrzemyslawKlys commented 3 years ago

If you want to play with Html in the tables you need to use InvokeHTMLTags switch. Otherwise, it treats HTML tags as text.

Natively you can do it using the proper new line PowerShell way.

$Array = @(
    [PSCustomObject] @{
        Test  = "Multiline" + [System.Environment]::NewLine + "Text"
        Test2 = "Multiline" + [System.Environment]::NewLine + "Text"
        Test3 = "Multiline" + [System.Environment]::NewLine + "Text"
    }
    [PSCustomObject] @{
        Test  = "Multiline" + [System.Environment]::NewLine + "Text"
        Test2 = "Multiline" + [System.Environment]::NewLine + "Text"
        Test3 = "Multiline" + [System.Environment]::NewLine + "Text"
    }
)
$Array | Out-HtmlView
raymix commented 3 years ago

Thank you so much, it works great @PrzemyslawKlys

Here's what I ended up using:

@("One", "Two", "Three") -join [System.Environment]::NewLine