mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
Can simply view with [[Something]]
This commit is contained in:
parent
40537cd672
commit
01a91422d9
@ -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).
|
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
|
## 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
|
## 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.
|
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.
|
||||||
|
@ -94,6 +94,10 @@ func serveStaticFile(c *gin.Context, option string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func renderMarkdown(c *gin.Context, currentText string, title string, versions []versionsInfo) {
|
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))
|
unsafe := blackfriday.MarkdownCommon([]byte(currentText))
|
||||||
pClean := bluemonday.UGCPolicy()
|
pClean := bluemonday.UGCPolicy()
|
||||||
pClean.AllowElements("img")
|
pClean.AllowElements("img")
|
||||||
@ -102,7 +106,7 @@ func renderMarkdown(c *gin.Context, currentText string, title string, versions [
|
|||||||
pClean.AllowDataURIImages()
|
pClean.AllowDataURIImages()
|
||||||
html := pClean.SanitizeBytes(unsafe)
|
html := pClean.SanitizeBytes(unsafe)
|
||||||
html2 := string(html)
|
html2 := string(html)
|
||||||
r, _ := regexp.Compile("\\$\\$(.*?)\\$\\$")
|
r, _ = regexp.Compile("\\$\\$(.*?)\\$\\$")
|
||||||
for _, s := range r.FindAllString(html2, -1) {
|
for _, s := range r.FindAllString(html2, -1) {
|
||||||
html2 = strings.Replace(html2, s, "<span class='texp' data-expr='"+s[2:len(s)-2]+"'></span>", 1)
|
html2 = strings.Replace(html2, s, "<span class='texp' data-expr='"+s[2:len(s)-2]+"'></span>", 1)
|
||||||
}
|
}
|
||||||
@ -112,6 +116,8 @@ func renderMarkdown(c *gin.Context, currentText string, title string, versions [
|
|||||||
}
|
}
|
||||||
|
|
||||||
html2 = strings.Replace(html2, "&#36;", "$", -1)
|
html2 = strings.Replace(html2, "&#36;", "$", -1)
|
||||||
|
html2 = strings.Replace(html2, "&#91;", "[", -1)
|
||||||
|
html2 = strings.Replace(html2, "&#93;", "]", -1)
|
||||||
c.HTML(http.StatusOK, "view.tmpl", gin.H{
|
c.HTML(http.StatusOK, "view.tmpl", gin.H{
|
||||||
"Title": title,
|
"Title": title,
|
||||||
"WikiName": RuntimeArgs.WikiName,
|
"WikiName": RuntimeArgs.WikiName,
|
||||||
|
@ -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).
|
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
|
## 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
|
## 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.
|
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.
|
||||||
|
Loading…
Reference in New Issue
Block a user