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
This commit is contained in:
Zack 2016-02-07 13:21:58 -05:00
commit 4bd0d8a69a
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>