Launcher: Render help document contents using Markdown

Change-Id: I580c56bff201cd508efd52ba75eed28a8869f9b1
diff --git a/core/installer/welcome/launcher.go b/core/installer/welcome/launcher.go
index 7816dfc..fe80fe0 100644
--- a/core/installer/welcome/launcher.go
+++ b/core/installer/welcome/launcher.go
@@ -9,6 +9,8 @@
 	"strings"
 
 	"github.com/giolekva/pcloud/core/installer"
+
+	"github.com/gomarkdown/markdown"
 )
 
 //go:embed launcher-tmpl/launcher.html
@@ -20,10 +22,16 @@
 type AppLauncherInfo struct {
 	Name string
 	Icon template.HTML
-	Help []installer.HelpDocument
+	Help []HelpDocumentRendered
 	Url  string
 }
 
+type HelpDocumentRendered struct {
+	Title    string
+	Contents template.HTML
+	Children []HelpDocumentRendered
+}
+
 type AppDirectory interface {
 	GetAllApps() ([]AppLauncherInfo, error)
 }
@@ -45,7 +53,7 @@
 		ret = append(ret, AppLauncherInfo{
 			Name: a.AppId,
 			Icon: template.HTML(a.Icon),
-			Help: a.Help,
+			Help: toMarkdown(a.Help),
 			Url:  a.URL,
 		})
 	}
@@ -136,3 +144,18 @@
 		return
 	}
 }
+
+func toMarkdown(help []installer.HelpDocument) []HelpDocumentRendered {
+	if help == nil {
+		return nil
+	}
+	var ret []HelpDocumentRendered
+	for _, h := range help {
+		ret = append(ret, HelpDocumentRendered{
+			Title:    h.Title,
+			Contents: template.HTML(markdown.ToHTML([]byte(h.Contents), nil, nil)),
+			Children: toMarkdown(h.Children),
+		})
+	}
+	return ret
+}