Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F13779019
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
View Options
diff --git a/templates/include/render.tmpl b/templates/include/render.tmpl
index 4d7e545..06b650b 100644
--- a/templates/include/render.tmpl
+++ b/templates/include/render.tmpl
@@ -1,33 +1,47 @@
<!-- Miscelaneous render related template parts we use multiple times -->
{{define "highlighting"}}
<!-- TODO: make this conditional on presence of code blocks -->
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/styles/atom-one-light.min.css"/>
- <script type="text/javascript"
- src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/highlight.min.js" async></script>
<script>
- addEventListener('load', function () {
- var x = document.querySelectorAll("code[class^='language-']");
- for (i=0; i<x.length; i++) {
- hljs.highlightBlock(x[i]);
- }});
+ // 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, stuff, so we load css + js
+ var s=document.createElement('script');
+ s.type="text/javascript"; s.src= hlbaseUri + "highlight.min.js"; s.async=true;
+
+ // Here's the crux, we need to react on load event for this new element to make it work.
+ s.onload = () => { highlight(x) }
+ document.getElementsByTagName('head')[0].appendChild(s);
+
+ // Gives a set of nodes, run highlighting on them
+ function highlight(nodes) {
+ for (i=0; i<nodes.length; i++) {
+ hljs.highlightBlock(nodes[i]);
+ }
+ }
+ }
+ });
</script>
{{end}}
<!-- 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}}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Jan 29, 9:13 PM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3608307
Attached To
rWF WriteFreely
Event Timeline
Log In to Comment