Fix whitespace in highlight JS
This commit is contained in:
parent
a54f5fc9d8
commit
246a6dc554
|
@ -1,32 +1,35 @@
|
||||||
<!-- Miscelaneous render related template parts we use multiple times -->
|
<!-- Miscelaneous render related template parts we use multiple times -->
|
||||||
{{define "highlighting"}}
|
{{define "highlighting"}}
|
||||||
<script>
|
<script>
|
||||||
// TODO: this feels more like a mutation observer
|
// TODO: this feels more like a mutation observer
|
||||||
addEventListener('DOMContentLoaded', function () {
|
addEventListener('DOMContentLoaded', function () {
|
||||||
var hlbaseUri="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/";
|
var hlbaseUri = "//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/";
|
||||||
var x=document.querySelectorAll("code[class^='language-']");
|
var x = document.querySelectorAll("code[class^='language-']");
|
||||||
if (x.length > 0 ) {
|
if (x.length > 0) {
|
||||||
// We have blocks to be highlighted, so we load css + js
|
// We have blocks to be highlighted, so we load css + js
|
||||||
var st=document.createElement('link');
|
var st = document.createElement('link');
|
||||||
st.rel="stylesheet"; st.href=hlbaseUri + "styles/atom-one-light.min.css";
|
st.rel = "stylesheet";
|
||||||
document.getElementsByTagName('head')[0].appendChild(st);
|
st.href = hlbaseUri + "styles/atom-one-light.min.css";
|
||||||
|
document.getElementsByTagName('head')[0].appendChild(st);
|
||||||
|
|
||||||
var sc=document.createElement('script');
|
var sc = document.createElement('script');
|
||||||
sc.type="text/javascript"; sc.src=hlbaseUri + "highlight.min.js"; sc.async=true;
|
sc.type = "text/javascript";
|
||||||
|
sc.src = hlbaseUri + "highlight.min.js";
|
||||||
|
sc.async = true;
|
||||||
|
|
||||||
// Here's the crux, we need to react on load event for this new element to make it work.
|
// Here's the crux, we need to react on load event for this new element to make it work.
|
||||||
sc.onload=() => { highlight(x) }
|
sc.onload = () => { highlight(x) }
|
||||||
document.getElementsByTagName('head')[0].appendChild(sc);
|
document.getElementsByTagName('head')[0].appendChild(sc);
|
||||||
|
|
||||||
// Given a set of nodes, run highlighting on them
|
// Given a set of nodes, run highlighting on them
|
||||||
function highlight(nodes) {
|
function highlight(nodes) {
|
||||||
for (i=0; i < nodes.length; i++) {
|
for (i=0; i < nodes.length; i++) {
|
||||||
hljs.highlightBlock(nodes[i]);
|
hljs.highlightBlock(nodes[i]);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
</script>
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
<!-- Include mathjax configuration -->
|
<!-- Include mathjax configuration -->
|
||||||
|
@ -43,6 +46,5 @@
|
||||||
"HTML-CSS": { fonts: ["TeX"] }
|
"HTML-CSS": { fonts: ["TeX"] }
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript"
|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" async></script>
|
||||||
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" async></script>
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Loading…
Reference in New Issue