Skip to content

Commit

Permalink
fix: support newlines in md report
Browse files Browse the repository at this point in the history
  • Loading branch information
mhrabovcin committed Feb 19, 2024
1 parent 24dfc52 commit 994fa1e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .github/actions/copacetic-action/pkg/patch/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package patch
import (
"encoding/json"
"errors"
"fmt"
"io"
"strings"

md "github.com/go-spectest/markdown"

Expand Down Expand Up @@ -56,7 +58,7 @@ func WriteMarkdown(report Report, w io.Writer) error {
}
for i := range mdRow {
if len(mdRow[i]) > 0 {
mdRow[i] = md.Code(mdRow[i])
mdRow[i] = codeForTable(mdRow[i])
}
}
imagesTable.Rows = append(imagesTable.Rows, mdRow)
Expand All @@ -65,3 +67,7 @@ func WriteMarkdown(report Report, w io.Writer) error {
doc.H2("Patched images").PlainText("").Table(imagesTable)
return doc.Build()
}

func codeForTable(s string) string {
return fmt.Sprintf("<pre>%s</pre>", strings.ReplaceAll(s, "\n", "<br/>"))
}

0 comments on commit 994fa1e

Please sign in to comment.