Replace break line characters with HTML notation when exporting to markdown (#3014)

* Fixes #2997, replace break line characters with HTML notation to avoid render the field text in a new line.

* using short helper

Co-authored-by: Víctor Zamanillo <victor.zamanillo@cifraeducacion.com>
Co-authored-by: sandeep <8293321+ehsandeep@users.noreply.github.com>
Co-authored-by: Mzack9999 <mzack9999@protonmail.com>
dev
Víctor 2022-12-15 14:00:40 +01:00 committed by GitHub
parent a19385376c
commit fd59841372
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -160,8 +160,8 @@ func ToMarkdownTableString(templateInfo *model.Info) string {
fields.Set("Authors", templateInfo.Authors.String())
fields.Set("Tags", templateInfo.Tags.String())
fields.Set("Severity", templateInfo.SeverityHolder.Severity.String())
fields.Set("Description", templateInfo.Description)
fields.Set("Remediation", templateInfo.Remediation)
fields.Set("Description", lineBreakToHTML(templateInfo.Description))
fields.Set("Remediation", lineBreakToHTML(templateInfo.Remediation))
classification := templateInfo.Classification
if classification != nil {
@ -239,3 +239,7 @@ func createMarkdownCodeBlock(title string, content string, language string) stri
func createBoldMarkdown(value string) string {
return "**" + value + "**"
}
func lineBreakToHTML(text string) string {
return strings.ReplaceAll(text, "\n", "<br>")
}