initial
This commit is contained in:
20
themes/next/layout/_third-party/math/index.swig
vendored
Normal file
20
themes/next/layout/_third-party/math/index.swig
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
{% if theme.math.enable %}
|
||||
{% set is_index_has_math = false %}
|
||||
|
||||
{# At home, check if there has `mathjax: true` post #}
|
||||
{% if is_home() %}
|
||||
{% for post in page.posts %}
|
||||
{% if post.mathjax and not is_index_has_math %}
|
||||
{% set is_index_has_math = true %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% if not theme.math.per_page or (is_index_has_math or page.mathjax) %}
|
||||
{% if theme.math.engine == 'mathjax' %}
|
||||
{% include 'mathjax.swig' %}
|
||||
{% elif theme.math.engine == 'katex' %}
|
||||
{% include 'katex.swig' %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
9
themes/next/layout/_third-party/math/katex.swig
vendored
Normal file
9
themes/next/layout/_third-party/math/katex.swig
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
<link rel="stylesheet" href="{{ theme.math.katex.cdn }}"/>
|
||||
{% if theme.math.katex.copy_tex.enable %}
|
||||
{% if theme.math.katex.copy_tex.copy_tex_js %}
|
||||
<script src="{{ theme.math.katex.copy_tex.copy_tex_js }}"></script>
|
||||
{% endif %}
|
||||
{% if theme.math.katex.copy_tex.copy_tex_css %}
|
||||
<link rel="stylesheet" href="{{ theme.math.katex.copy_tex.copy_tex_css }}"/>
|
||||
{% endif %}
|
||||
{% endif %}
|
40
themes/next/layout/_third-party/math/mathjax.swig
vendored
Normal file
40
themes/next/layout/_third-party/math/mathjax.swig
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
<script type="text/x-mathjax-config">
|
||||
{% if theme.math.mathjax.mhchem %}
|
||||
MathJax.Ajax.config.path['mhchem'] = '{{ theme.math.mathjax.mhchem }}';
|
||||
{% endif %}
|
||||
|
||||
MathJax.Hub.Config({
|
||||
tex2jax: {
|
||||
inlineMath: [ ['$', '$'], ['\\(', '\\)'] ],
|
||||
processEscapes: true,
|
||||
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
|
||||
},
|
||||
TeX: {
|
||||
{% if theme.math.mathjax.mhchem %}
|
||||
extensions: ['[mhchem]/mhchem.js'],
|
||||
{% endif %}
|
||||
equationNumbers: {
|
||||
autoNumber: 'AMS'
|
||||
}
|
||||
}
|
||||
});
|
||||
MathJax.Hub.Register.StartupHook('TeX Jax Ready', function() {
|
||||
MathJax.InputJax.TeX.prefilterHooks.Add(function(data) {
|
||||
if (data.display) {
|
||||
var next = data.script.nextSibling;
|
||||
while (next && next.nodeName.toLowerCase() === '#text') { next = next.nextSibling }
|
||||
if (next && next.nodeName.toLowerCase() === 'br') { next.parentNode.removeChild(next) }
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Queue(function() {
|
||||
var all = MathJax.Hub.getAllJax(), i;
|
||||
for (i = 0; i < all.length; i += 1) {
|
||||
document.getElementById(all[i].inputID + '-Frame').parentNode.className += ' has-jax';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script src="{{ theme.math.mathjax.cdn }}"></script>
|
Reference in New Issue
Block a user