From 09b09f3dbc7b4c237e0dd49fcd5fd6ede7e9e7c5 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Sat, 10 Sep 2016 07:06:20 -0400 Subject: [PATCH] Fix #57 Former-commit-id: 8a967397a0af8dedcc36f56bb9adca904f77705f [formerly 84097c863b5c0b6036fb4d4757b0b56bdbd41192] [formerly adc17b2404fa552efaebf485f6f30a412ae90f9a [formerly a43305f34b1c5a4a1f29b198604d2dbe1b127bab [formerly 87e54398545e449157d0108da6a3baedc45682ac]]] Former-commit-id: bd94b8dacfc04010499567541d5313dae6dc89fa [formerly 874671aa7538960f6ac236a11f4fdff8d2d3a994] Former-commit-id: 517229eb395c1cda4d125ad2014240112d9fff64 Former-commit-id: 0a4549d3a7360ff56586197fe4a3ca518fd6b7c0 --- routes.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/routes.go b/routes.go index 0047bf0..b16ccc7 100644 --- a/routes.go +++ b/routes.go @@ -474,6 +474,12 @@ func renderList(c *gin.Context, title string) { c.Redirect(302, "/"+title+"/view") } + // Convert [[page]] to [page](/page/view) + r, _ := regexp.Compile("\\[\\[(.*?)\\]\\]") + for _, s := range r.FindAllString(p.CurrentText, -1) { + p.CurrentText = strings.Replace(p.CurrentText, s, "["+s[2:len(s)-2]+"](/"+s[2:len(s)-2]+"/view)", 1) + } + pClean := bluemonday.UGCPolicy() pClean.AllowElements("img") pClean.AllowAttrs("alt").OnElements("img")