diff --git a/ConfluencePS/Public/ConvertTo-StorageFormat.ps1 b/ConfluencePS/Public/ConvertTo-StorageFormat.ps1 index 7931ef3..21a1963 100644 --- a/ConfluencePS/Public/ConvertTo-StorageFormat.ps1 +++ b/ConfluencePS/Public/ConvertTo-StorageFormat.ps1 @@ -18,7 +18,8 @@ function ConvertTo-StorageFormat { Mandatory = $true, ValueFromPipeline = $true )] - [string[]]$Content + [string[]]$Content, + [System.Management.Automation.SwitchParameter]$AsPlainText ) BEGIN { @@ -29,6 +30,27 @@ function ConvertTo-StorageFormat { Write-Debug "[$($MyInvocation.MyCommand.Name)] ParameterSetName: $($PsCmdlet.ParameterSetName)" Write-Debug "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)" + if ($AsPlainText) + { + Write-Verbose "[$($MyInvocation.MyCommand.Name)] Replace special chars with ascii code" + [System.Collections.Hashtable]$SpecialChars = @{ + '#' = '#' + '@' = '@' + '[' = '[' + ']' = ']' + '{' = '{' + '}' = 'Ӊ' + } + + foreach ($Key in $SpecialChars.Keys) + { + for ($i = 0; $i -lt $Content.Count; $i ++) + { + $Content[$i] = $Content[$i].Replace($Key, $SpecialChars.$Key) + } + } + } + $iwParameters = Copy-CommonParameter -InputObject $PSBoundParameters $iwParameters['Uri'] = "$ApiUri/contentbody/convert/storage" $iwParameters['Method'] = 'Post'