mirror of https://github.com/writeas/writefreely
A focused writing and publishing space.
https://write.with.parts
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.7 KiB
51 lines
1.7 KiB
6 years ago
|
<!-- Miscelaneous render related template parts we use multiple times -->
|
||
|
{{define "highlighting"}}
|
||
6 years ago
|
<script>
|
||
|
// TODO: this feels more like a mutation observer
|
||
|
addEventListener('DOMContentLoaded', function () {
|
||
|
var hlbaseUri = "//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/";
|
||
|
var x = document.querySelectorAll("code[class^='language-']");
|
||
|
if (x.length > 0) {
|
||
|
// We have blocks to be highlighted, so we load css + js
|
||
|
var st = document.createElement('link');
|
||
|
st.rel = "stylesheet";
|
||
|
st.href = hlbaseUri + "styles/atom-one-light.min.css";
|
||
|
document.getElementsByTagName('head')[0].appendChild(st);
|
||
6 years ago
|
|
||
6 years ago
|
var sc = document.createElement('script');
|
||
|
sc.type = "text/javascript";
|
||
|
sc.src = hlbaseUri + "highlight.min.js";
|
||
|
sc.async = true;
|
||
6 years ago
|
|
||
6 years ago
|
// Here's the crux, we need to react on load event for this new element to make it work.
|
||
|
sc.onload = () => { highlight(x) }
|
||
|
document.getElementsByTagName('head')[0].appendChild(sc);
|
||
6 years ago
|
|
||
6 years ago
|
// Given a set of nodes, run highlighting on them
|
||
|
function highlight(nodes) {
|
||
|
for (i=0; i < nodes.length; i++) {
|
||
|
hljs.highlightBlock(nodes[i]);
|
||
6 years ago
|
}
|
||
6 years ago
|
}
|
||
|
}
|
||
|
});
|
||
|
</script>
|
||
6 years ago
|
{{end}}
|
||
6 years ago
|
|
||
|
<!-- Include mathjax configuration -->
|
||
|
{{define "mathjax"}}
|
||
|
<script type="text/x-mathjax-config">
|
||
|
MathJax.Hub.Config({
|
||
|
extensions: ["tex2jax.js"],
|
||
|
jax: ["input/TeX", "output/HTML-CSS"],
|
||
|
tex2jax: {
|
||
|
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
|
||
|
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
|
||
|
processEscapes: true
|
||
|
},
|
||
|
"HTML-CSS": { fonts: ["TeX"] }
|
||
|
});
|
||
|
</script>
|
||
6 years ago
|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" async></script>
|
||
6 years ago
|
{{end}}
|