2017-05-28 118 views
1

這段代碼發佈在Hugo的MathJax支持頁面中。我把它插入一個部分(例如,head.html)。Hugo在部分代碼中跳過了Javascript,代碼被破壞

<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> 

的頁面加載時,瀏覽器嘗試執行它,而是寫在控制檯例外:

VM14379:7 Uncaught SyntaxError: Unexpected token ; 
at eval (<anonymous>) 

我點擊該行並看到:

enter image description here

我是對的,因爲<已經逃脫了?如何解決它?

編輯:移動這my-theme/layouts/index.html作出的代碼完全呈現的頁面消失在layouts/_default/single.html它還是引起了同樣的錯誤。)

雨果的版本是0.21。

回答

1

找到解決方案:將type="text/x-mathjax-config"更改爲type="text/javascript",並且一切正常。