Reputation: 36513
This snippet is published in MathJax support page in Hugo. I take it and insert into a partial (say, head.html
).
<script type="text/x-mathjax-config">
MathJax.Hub.Queue(function() {
// Fix <code> tags after MathJax finishes running. This is a
// hack to overcome a shortcoming of Markdown. Discussion at
// https://github.com/mojombo/jekyll/issues/199
var all = MathJax.Hub.getAllJax(), i;
for(i = 0; i < all.length; i += 1) {
all[i].SourceElement().parentNode.className += ' has-jax';
}
});
</script>
When the page loads, the browser tries to execute it, but writes an exception in Console:
VM14379:7 Uncaught SyntaxError: Unexpected token ;
at eval (<anonymous>)
I click that line and see this:
Am I right that it's because <
was escaped? How to fix it?
(edit: moving this to my-theme/layouts/index.html
made the code disappear from the rendered page completely. In layouts/_default/single.html
it still causes the same error.)
Hugo version is 0.21.
Upvotes: 2
Views: 537
Reputation: 36513
Found the solution: changed type="text/x-mathjax-config"
to type="text/javascript"
, and everything worked perfectly.
Upvotes: 1