diff --git a/README.md b/README.md index 51631b6..a6f19ee 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This is a self-contained wiki webserver that makes sharing easy and _fast_. You To jot a note, simply load the page at [`/`](http://AwwKoala.com/) and just start typing. No need to press edit, the browser will already be focused on the text. No need to press save - it will automatically save when you stop writing. The URL at [`/`](http://AwwKoala.com/) will redirect to an easy-to-remember name that you can use to reload the page at anytime, anywhere. But, you can also use any URL you want, e.g. [`/AnythingYouWant`](http://AwwKoala.com/AnythingYouWant). ## Views -All pages can be rendered into HTML by adding `/view`. For example, the page [`/AnythingYouWant`](http://AwwKoala.com/AnythingYouWant) is rendered at [`/AnythingYouWant/view`](http://AwwKoala.com/AnythingYouWant/view). You can write in HTML or [Markdown](https://daringfireball.net/projects/markdown/) for page rendering. Math is supported with [Katex](https://github.com/Khan/KaTeX) using `$\frac{1}{2}$` for inline equations and `$$\frac{1}{2}$$` for regular equations. +All pages can be rendered into HTML by adding `/view`. For example, the page [`/AnythingYouWant`](http://AwwKoala.com/AnythingYouWant) is rendered at [`/AnythingYouWant/view`](http://AwwKoala.com/AnythingYouWant/view). You can write in HTML or [Markdown](https://daringfireball.net/projects/markdown/) for page rendering. To quickly link to `/view` pages, just use `[[AnythingYouWnat]]`. Math is supported with [Katex](https://github.com/Khan/KaTeX) using `$\frac{1}{2}$` for inline equations and `$$\frac{1}{2}$$` for regular equations. ## Lists If you are writing a list and you want to tick off things really easily, just add `/list`. For example, after editing [`/grocery`](http://AwwKoala.com/grocery), goto [`/grocery/list`](http://AwwKoala.com/grocery/list). In this page, whatever you click on will be striked through and moved to the end. This is helpful if you write a grocery list and then want to easily delete things from it. diff --git a/routes.go b/routes.go index 9b2a192..040e140 100644 --- a/routes.go +++ b/routes.go @@ -94,6 +94,10 @@ func serveStaticFile(c *gin.Context, option string) { } func renderMarkdown(c *gin.Context, currentText string, title string, versions []versionsInfo) { + r, _ := regexp.Compile("\\[\\[(.*?)\\]\\]") + for _, s := range r.FindAllString(currentText, -1) { + currentText = strings.Replace(currentText, s, "["+s[2:len(s)-2]+"](/"+s[2:len(s)-2]+"/view)", 1) + } unsafe := blackfriday.MarkdownCommon([]byte(currentText)) pClean := bluemonday.UGCPolicy() pClean.AllowElements("img") @@ -102,7 +106,7 @@ func renderMarkdown(c *gin.Context, currentText string, title string, versions [ pClean.AllowDataURIImages() html := pClean.SanitizeBytes(unsafe) html2 := string(html) - r, _ := regexp.Compile("\\$\\$(.*?)\\$\\$") + r, _ = regexp.Compile("\\$\\$(.*?)\\$\\$") for _, s := range r.FindAllString(html2, -1) { html2 = strings.Replace(html2, s, "", 1) } @@ -112,6 +116,8 @@ func renderMarkdown(c *gin.Context, currentText string, title string, versions [ } html2 = strings.Replace(html2, "$", "$", -1) + html2 = strings.Replace(html2, "[", "[", -1) + html2 = strings.Replace(html2, "]", "]", -1) c.HTML(http.StatusOK, "view.tmpl", gin.H{ "Title": title, "WikiName": RuntimeArgs.WikiName, diff --git a/templates/aboutpage.md b/templates/aboutpage.md index cb5a780..6353320 100644 --- a/templates/aboutpage.md +++ b/templates/aboutpage.md @@ -11,7 +11,7 @@ This is a self-contained wiki webserver that makes sharing easy and _fast_. You To jot a note, simply load the page at [`/`](/) and just start typing. No need to press edit, the browser will already be focused on the text. No need to press save - it will automatically save when you stop writing. The URL at [`/`](/) will redirect to an easy-to-remember name that you can use to reload the page at anytime, anywhere. But, you can also use any URL you want, e.g. [`/AnythingYouWant`](/AnythingYouWant). ## Views -All pages can be rendered into HTML by adding `/view`. For example, the page [`/AnythingYouWant`](/AnythingYouWant) is rendered at [`/AnythingYouWant/view`](/AnythingYouWant/view). You can write in HTML or [Markdown](https://daringfireball.net/projects/markdown/) for page rendering. Math is supported with [Katex](https://github.com/Khan/KaTeX) using `$\frac{1}{2}$` for inline equations and `$$\frac{1}{2}$$` for regular equations. +All pages can be rendered into HTML by adding `/view`. For example, the page [`/AnythingYouWant`](/AnythingYouWant) is rendered at [`/AnythingYouWant/view`](/AnythingYouWant/view). You can write in HTML or [Markdown](https://daringfireball.net/projects/markdown/) for page rendering. To quickly link to `/view` pages, just use `[[AnythingYouWant]]`. Math is supported with [Katex](https://github.com/Khan/KaTeX) using `$\frac{1}{2}$` for inline equations and `$$\frac{1}{2}$$` for regular equations. ## Lists If you are writing a list and you want to tick off things really easily, just add `/list`. For example, after editing [`/grocery`](/grocery), goto [`/grocery/list`](/grocery/list). In this page, whatever you click on will be striked through and moved to the end. This is helpful if you write a grocery list and then want to easily delete things from it.