1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00

Merge pull request #4 from schollz/math

Works

Former-commit-id: 28099fa7cf5384431b7e8e8e90fbad4c0762ef35 [formerly 15072873d3a0ef2d3e6cf14c020676fbe43e7315] [formerly 39d30f3c06cb065d34468730e0b2dbd05dd6d4b5 [formerly 181644c38700fa0dce26767708c65ba049ed28c7 [formerly 4bd0d8a69a]]]
Former-commit-id: e972807a33606a72b481ec943f21030ec0549315 [formerly ed4f2e145591e31f3d4dafe1ceb1b9bb86c543d0]
Former-commit-id: 6dae915a3825988e96563440a0ca2cea3bce75f5
Former-commit-id: bd4dd360cd
This commit is contained in:
Zack 2016-02-07 13:21:58 -05:00
commit b14de24d6f
82 changed files with 22 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import (
"html/template"
"io/ioutil"
"net/http"
"regexp"
"strconv"
"strings"
@ -62,9 +63,16 @@ func renderMarkdown(c *gin.Context, title string) {
}
unsafe := blackfriday.MarkdownCommon([]byte(p.Text))
html := bluemonday.UGCPolicy().SanitizeBytes(unsafe)
html2 := string(html)
r, _ := regexp.Compile("\\$(.*?)\\$")
for _, s := range r.FindAllString(html2, -1) {
html2 = strings.Replace(html2, s, "<div class='tex' data-expr='"+s[1:len(s)-1]+"'></div>", 1)
}
c.HTML(http.StatusOK, "view.tmpl", gin.H{
"Title": title,
"Body": template.HTML(html),
"Body": template.HTML([]byte(html2)),
})
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -7,7 +7,8 @@
{{ template "header" }}
<link rel="stylesheet" type="text/css" href="/static/css/view.css">
<link rel="stylesheet" type="text/css" href="/static/css/katex.min.css">
<script src="/static/js/katex.min.js"></script>
</head>
@ -42,6 +43,17 @@
</div>
<script>
$( document ).ready(function() {
var tex = document.getElementsByClassName("tex");
Array.prototype.forEach.call(tex, function(el) {
katex.render(el.getAttribute("data-expr"), el);
});
});
</script>
</body>
</html>