From 3755e42a75ae4eaee257c3408e75cff5dee5dd44 Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Sun, 24 May 2020 20:40:41 +0200 Subject: [PATCH] Render markdown with goldmark --- backref.go | 12 ++++-------- main.go | 7 +------ 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/backref.go b/backref.go index 9a37506..c8cd764 100644 --- a/backref.go +++ b/backref.go @@ -6,8 +6,6 @@ import ( "os" "path/filepath" "strings" - - "gitlab.com/golang-commonmark/markdown" ) type Reference struct { @@ -85,21 +83,19 @@ func loadBackrefs(fp *FilePages, p string) (map[string][]Backref, error) { result := make(map[string][]Backref) - md := markdown.New( - markdown.HTML(true), - markdown.XHTMLOutput(true), - ) - for _, ref := range refs[p] { title := strings.Replace(ref.Name, "_", " ", -1) if _, e := result[ref.Name]; !e { result[ref.Name] = nil } + links := renderLinks(strings.TrimLeft(ref.Link.Line, " *")) + pageText := renderMarkdown2(links) + result[ref.Name] = append(result[ref.Name], Backref{ Name: ref.Name, Title: title, - Line: template.HTML(md.RenderToString([]byte(renderLinks(strings.TrimLeft(ref.Link.Line, " *"))))), + Line: template.HTML(pageText), }) } diff --git a/main.go b/main.go index 4aa25ea..e29b7f5 100644 --- a/main.go +++ b/main.go @@ -13,7 +13,6 @@ import ( "strings" "time" - "gitlab.com/golang-commonmark/markdown" "p83.nl/go/ekster/pkg/util" "p83.nl/go/indieauth" ) @@ -482,11 +481,7 @@ func (h *indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { pageText = renderLinks(pageText) - md := markdown.New( - markdown.HTML(true), - markdown.XHTMLOutput(true), - ) - pageText = md.RenderToString([]byte(pageText)) + pageText = renderMarkdown2(pageText) pageBase := getPageBase() data := indexPage{