2018-11-20 20:51:39 +00:00
|
|
|
<!-- Miscelaneous render related template parts we use multiple times -->
|
|
|
|
{{define "highlighting"}}
|
|
|
|
<script>
|
2018-11-22 13:31:25 +00:00
|
|
|
// TODO: this feels more like a mutation observer
|
|
|
|
addEventListener('DOMContentLoaded', function () {
|
|
|
|
var hlbaseUri="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/";
|
2018-11-22 14:01:11 +00:00
|
|
|
var x=document.querySelectorAll("code[class^='language-']");
|
2018-11-22 13:31:25 +00:00
|
|
|
if (x.length > 0 ) {
|
2018-11-22 15:03:44 +00:00
|
|
|
// We have blocks to be highlighted, so we load css + js
|
2018-11-22 14:01:11 +00:00
|
|
|
var st=document.createElement('link');
|
|
|
|
st.rel="stylesheet"; st.href=hlbaseUri + "styles/atom-one-light.min.css";
|
|
|
|
document.getElementsByTagName('head')[0].appendChild(st);
|
|
|
|
|
|
|
|
var sc=document.createElement('script');
|
|
|
|
sc.type="text/javascript"; sc.src=hlbaseUri + "highlight.min.js"; sc.async=true;
|
2018-11-22 13:31:25 +00:00
|
|
|
|
|
|
|
// Here's the crux, we need to react on load event for this new element to make it work.
|
2018-11-22 14:01:11 +00:00
|
|
|
sc.onload=() => { highlight(x) }
|
|
|
|
document.getElementsByTagName('head')[0].appendChild(sc);
|
2018-11-22 13:31:25 +00:00
|
|
|
|
2018-11-22 15:03:44 +00:00
|
|
|
// Given a set of nodes, run highlighting on them
|
2018-11-22 13:31:25 +00:00
|
|
|
function highlight(nodes) {
|
2018-11-22 14:01:11 +00:00
|
|
|
for (i=0; i < nodes.length; i++) {
|
2018-11-22 13:31:25 +00:00
|
|
|
hljs.highlightBlock(nodes[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2018-11-20 20:51:39 +00:00
|
|
|
</script>
|
|
|
|
{{end}}
|
2018-11-20 21:01:25 +00:00
|
|
|
|
|
|
|
<!-- 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>
|
|
|
|
<script type="text/javascript"
|
|
|
|
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" async></script>
|
|
|
|
{{end}}
|