Created
October 15, 2016 20:22
-
-
Save odinuge/0b8ed30309fdaeadfdae614d10334213 to your computer and use it in GitHub Desktop.
Katex-support in gogs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl | |
index 68e8444..38c790c 100644 | |
--- a/templates/repo/view_file.tmpl | |
+++ b/templates/repo/view_file.tmpl | |
@@ -76,3 +76,26 @@ function submitDeleteForm() { | |
} | |
} | |
</script> | |
+ | |
+{{if .IsMarkdown}} | |
+<script src="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.js"></script> | |
+<script src="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/contrib/auto-render.min.js"></script> | |
+<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.css"> | |
+ | |
+<script> | |
+function renderMath() { | |
+ renderMathInElement( | |
+ document.getElementById("file-content"), | |
+ { | |
+ delimiters: [ | |
+ {left: "$$", right: "$$", display: true}, | |
+ {left: "\\[", right: "\\]", display: true}, | |
+ {left: "$", right: "$", display: false}, | |
+ {left: "\\(", right: "\\)", display: false} | |
+ ] | |
+ } | |
+ ); | |
+} | |
+renderMath(); | |
+</script> | |
+{{end}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment