Skip to content

Commit 29692b5

Browse files
Refactor command output formatting in coverage report to escape curly braces and enhance HTML rendering
1 parent cf7b9af commit 29692b5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

scripts/main.ps1

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ LogGroup 'Files analyzed' {
139139
# Transform the Command property with markdown code fences before building the table
140140
# --------------------------------------------------------------------------------
141141
$missedForDisplay = $codeCoverage.CommandsMissed | Sort-Object -Property File, Line | ForEach-Object {
142-
$command = '<pre><code class=''language-pwsh'' style="white-space: pre;">{0}</pre></code>' -f (Normalize-IndentationExceptFirst -Code $_.Command)
143-
$command = $command.Replace([Environment]::NewLine, '<br>').Replace(' ', '&nbsp;')
142+
$command = (Normalize-IndentationExceptFirst -Code $_.Command)
143+
$command = $command.Replace([Environment]::NewLine, '<br>').Replace(' ', '&nbsp;').Replace('{', '\{').Replace('}', '\}')
144+
$command = '<pre><code class=''language-pwsh''>{0}</pre></code>' -f $command
144145
[PSCustomObject]@{
145146
File = $_.File
146147
Line = $_.Line
@@ -154,8 +155,9 @@ $missedForDisplay = $codeCoverage.CommandsMissed | Sort-Object -Property File, L
154155
}
155156

156157
$executedForDisplay = $codeCoverage.CommandsExecuted | Sort-Object -Property File, Line | ForEach-Object {
157-
$command = '<pre><code class=''language-pwsh'' style="white-space: pre;">{0}</pre></code>' -f (Normalize-IndentationExceptFirst -Code $_.Command)
158-
$command = $command.Replace([Environment]::NewLine, '<br>').Replace(' ', '&nbsp;')
158+
$command = (Normalize-IndentationExceptFirst -Code $_.Command)
159+
$command = $command.Replace([Environment]::NewLine, '<br>').Replace(' ', '&nbsp;').Replace('{', '\{').Replace('}', '\}')
160+
$command = '<pre><code class=''language-pwsh''>{0}</pre></code>' -f $command
159161
[PSCustomObject]@{
160162
File = $_.File
161163
Line = $_.Line

0 commit comments

Comments
 (0)