iainbrighton / PScribo

PowerShell documentation framework
MIT License
230 stars 35 forks source link

[bug] Text plugin breaks Html/Word output #126

Closed shivtorov closed 1 year ago

shivtorov commented 1 year ago

Issue

When Text plugin is used together with Html/Word plugins, Html/Word output is broken.

Code to Reproduce the issue

$table1 = @(
    [PSCustomObject]@{ C1 = 'aaa'; C2 = @('a', 'aa', 'aaa') }
    [PSCustomObject]@{ C1 = 'bbb'; C2 = @('b', 'bb', 'bbb') }
    [PSCustomObject]@{ C1 = 'ccc'; C2 = @('c', 'cc', 'ccc') }
)

$doc = Document -Name 'Testing Object and String Arrays' {
    Table -InputObject $table1 -ColumnWidths 30, 70
}

Export-Document -Document $doc -Path 'D:\Temp\1\' -Format       Html, Word
Export-Document -Document $doc -Path 'D:\Temp\2\' -Format Text, Html, Word # broken tables

Observed Output

HTML/Word output in folder D:\Temp\1\ is good:

image

HTML/Word output in folder D:\Temp\2\ is bad:

image

Environment:

PS> Get-Module -Name PScribo

ModuleType Version    PreRelease Name
---------- -------    ---------- ----
Script     0.10.0                PScribo

PS> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.4
PSEdition                      Core
GitCommitId                    7.3.4
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
shivtorov commented 1 year ago

it appears that Text plugin modifies the original Document object. Thus, an immediate workaround for Pscribo user will be to ensure Text format is the last format in the list.

Export-Document -Document $doc -Format Html, Word, Text
iainbrighton commented 1 year ago

Fixed in https://github.com/iainbrighton/PScribo/commit/55f76d908aafe8b228c1ede9f1f46ffe4f46be25