From 56faa404991d0e9b15c8d16592cab37be36a4266 Mon Sep 17 00:00:00 2001 From: Umputun Date: Sun, 6 May 2018 17:15:35 -0500 Subject: [PATCH] no autolink --- app/rest/api/rest.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/rest/api/rest.go b/app/rest/api/rest.go index bdc84c4c..76417387 100644 --- a/app/rest/api/rest.go +++ b/app/rest/api/rest.go @@ -41,6 +41,10 @@ type Rest struct { amdminService admin } +var mdExt = blackfriday.NoIntraEmphasis | blackfriday.Tables | blackfriday.FencedCode | + blackfriday.Strikethrough | blackfriday.SpaceHeadings | blackfriday.HeadingIDs | + blackfriday.BackslashLineBreak + // Run the lister and request's router, activate rest server func (s *Rest) Run(port int) { log.Printf("[INFO] activate rest server on port %d", port) @@ -134,7 +138,7 @@ func (s *Rest) createCommentCtrl(w http.ResponseWriter, r *http.Request) { comment.PrepareUntrusted() // clean all fields user not suppoed to set comment.User = user comment.User.IP = strings.Split(r.RemoteAddr, ":")[0] - comment.Text = string(blackfriday.Run([]byte(comment.Text), blackfriday.WithExtensions(blackfriday.CommonExtensions))) + comment.Text = string(blackfriday.Run([]byte(comment.Text), blackfriday.WithExtensions(mdExt))) log.Printf("[DEBUG] create comment %+v", comment) // check if user blocked @@ -160,7 +164,7 @@ func (s *Rest) previewCommentCtrl(w http.ResponseWriter, r *http.Request) { rest.SendErrorJSON(w, r, http.StatusBadRequest, err, "can't bind comment") return } - comment.Text = string(blackfriday.Run([]byte(comment.Text), blackfriday.WithExtensions(blackfriday.CommonExtensions))) + comment.Text = string(blackfriday.Run([]byte(comment.Text), blackfriday.WithExtensions(mdExt))) render.HTML(w, r, comment.Text) }