PScribo Table doesn't handle newlines.
Closed this issue · 2 comments
vzabawski commented
I was trying to create a page with a table that contains newlines in its cells.
Here's an example code:
Import-Module -Name PScribo -Force
$ItemsArray = @()
$Item1 = [PSCustomObject] @{
Name = 'Sample text';
Description = "String1`nString2`nString3";
}
$Item2 = [PSCustomObject] @{
Name = 'Another sample text';
Description = "String1`nString2`nString3";
}
$ItemsArray += $Item1
$ItemsArray += $Item2
Document Example {
Table -Name "Example table" -InputObject $ItemsArray -Columns Name, Description
} | Export-Document -Path C:\Windows\Temp -Format html
Result:
I've tried a workaround from this issue but it didn't worked.
Result:
Environment:
Windows 10 Enterprise (Version 1803)
$PSVersionTable
Name Value
---- -----
PSVersion 5.1.17134.112
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17134.112
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PScribo version: 0.7.23.119
iainbrighton commented
Hi @vzabawski Internally the HTML plugin converts using the [System.Environment]::NewLine
enum for compatibility with both Windows and Linux. Therefore, on a Windows box you should use `r`n
like so:
Import-Module -Name PScribo -Force
$ItemsArray = @()
$Item1 = [PSCustomObject] @{
Name = 'Sample text';
Description = "String1`r`nString2`r`nString3";
}
$Item2 = [PSCustomObject] @{
Name = 'Another sample text';
Description = "String1`r`nString2`r`nString3";
}
$ItemsArray += $Item1
$ItemsArray += $Item2
Document Example {
Table -Name "Example table" -InputObject $ItemsArray -Columns Name, Description
} | Export-Document -Path C:\Windows\Temp -Format html
vzabawski commented
Thank you very much. It worked for me.