mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
Supports base64 images now
Former-commit-id: 1b543f804e763ac073ee76d3f8587d5a2ced1144 [formerly c01054eb87a0cb9738b529be9ca82d5a31c7d1b9] [formerly d9c64547e374965a8fbdad17ee9130f8bace0a38 [formerly 2b6303549e28f99fc514957e1dbfd591922039b6 [formerly8019335da0
]]] Former-commit-id: d5aae886478027d51bb4d75d17205f00509b4c5a [formerly 2d6dc42d8e610ed5823b3747d2167ba3231360e3] Former-commit-id: 6f0055b5e2336ead2974ad79e5759c0d67a75566 Former-commit-id:6f39dab8d6
This commit is contained in:
parent
0e4181fe3c
commit
aec437475b
@ -77,7 +77,12 @@ func serveStaticFile(c *gin.Context, option string) {
|
|||||||
|
|
||||||
func renderMarkdown(c *gin.Context, currentText string, title string) {
|
func renderMarkdown(c *gin.Context, currentText string, title string) {
|
||||||
unsafe := blackfriday.MarkdownCommon([]byte(currentText))
|
unsafe := blackfriday.MarkdownCommon([]byte(currentText))
|
||||||
html := bluemonday.UGCPolicy().SanitizeBytes(unsafe)
|
pClean := bluemonday.UGCPolicy()
|
||||||
|
pClean.AllowElements("img")
|
||||||
|
pClean.AllowAttrs("alt").OnElements("img")
|
||||||
|
pClean.AllowAttrs("src").OnElements("img")
|
||||||
|
pClean.AllowDataURIImages()
|
||||||
|
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) {
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
max-width: 700px;
|
max-width: 800px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user