diff --git a/infrastructure/code/code_html.go b/infrastructure/code/code_html.go
index 8aad75650..ec5b29a66 100644
--- a/infrastructure/code/code_html.go
+++ b/infrastructure/code/code_html.go
@@ -27,10 +27,9 @@ import (
"strings"
"time"
- "github.com/gomarkdown/markdown"
-
"github.com/snyk/snyk-ls/application/config"
"github.com/snyk/snyk-ls/domain/snyk"
+ "github.com/snyk/snyk-ls/internal/html"
"github.com/snyk/snyk-ls/internal/product"
)
@@ -66,8 +65,8 @@ var globalTemplate *template.Template
func init() {
funcMap := template.FuncMap{
"repoName": getRepoName,
- "trimCWEPrefix": trimCWEPrefix,
- "idxMinusOne": idxMinusOne,
+ "trimCWEPrefix": html.TrimCWEPrefix,
+ "idxMinusOne": html.IdxMinusOne,
}
var err error
@@ -92,9 +91,9 @@ func getCodeDetailsHtml(issue snyk.Issue) string {
"IssueTitle": additionalData.Title,
"IssueMessage": additionalData.Message,
"IssueType": getIssueType(additionalData),
- "SeverityIcon": getSeverityIconSvg(issue),
+ "SeverityIcon": html.GetSeverityIconSvg(issue),
"CWEs": issue.CWEs,
- "IssueOverview": markdownToHTML(additionalData.Text),
+ "IssueOverview": html.MarkdownToHTML(additionalData.Text),
"IsIgnored": issue.IsIgnored,
"DataFlow": additionalData.DataFlow,
"DataFlowTable": prepareDataFlowTable(additionalData),
@@ -105,7 +104,7 @@ func getCodeDetailsHtml(issue snyk.Issue) string {
"PriorityScore": additionalData.PriorityScore,
"SnykWebUrl": config.CurrentConfig().SnykUi(),
"LessonUrl": issue.LessonUrl,
- "LessonIcon": getLessonIconSvg(),
+ "LessonIcon": html.GetLessonIconSvg(),
"IgnoreLineAction": getLineToIgnoreAction(issue),
"HasAIFix": additionalData.HasAIFix,
"ExternalIcon": getExternalIconSvg(),
@@ -132,23 +131,10 @@ func getCodeDetailsHtml(issue snyk.Issue) string {
return html.String()
}
-func markdownToHTML(md string) template.HTML {
- html := markdown.ToHTML([]byte(md), nil, nil)
- return template.HTML(html)
-}
-
func getLineToIgnoreAction(issue snyk.Issue) int {
return issue.Range.Start.Line + 1
}
-func idxMinusOne(n int) int {
- return n - 1
-}
-
-func trimCWEPrefix(cwe string) string {
- return strings.TrimPrefix(cwe, "CWE-")
-}
-
func prepareIgnoreDetailsRow(ignoreDetails *snyk.IgnoreDetails) []IgnoreDetail {
return []IgnoreDetail{
{"Category", parseCategory(ignoreDetails.Category)},
@@ -279,33 +265,6 @@ func getExternalIconSvg() template.HTML {
`)
}
-func getSeverityIconSvg(issue snyk.Issue) template.HTML {
- switch issue.Severity {
- case snyk.Critical:
- return template.HTML(``)
- case snyk.High:
- return template.HTML(``)
- case snyk.Medium:
- return template.HTML(``)
- case snyk.Low:
- return template.HTML(``)
- default:
- return ``
- }
-}
-
func getGitHubIconSvg() template.HTML {
return template.HTML(`