提交 8f8cac20 编写于 作者: EvanOne(文一)'s avatar EvanOne(文一)

feat: Add mathjax & katex support

上级 f96db654
......@@ -51,4 +51,5 @@ link(rel="stylesheet" href=`${url_for(theme.css)}/index.css?v=${stun_env("versio
include ../_third-party/analytics/index.pug
include ../_third-party/search/index.pug
include ../_third-party/comments/index.pug
include ../_third-party/math/index.pug
include ./config.pug
......@@ -16,5 +16,3 @@ html(lang=config.language)
include ../_scripts/cdn.pug
include ../_scripts/common.pug
if is_post()
include ../_scripts/post.pug
......@@ -8,3 +8,6 @@ if theme.sidebar && theme.sidebar.enable
if theme.algolia_search.enable
script(src=`${ url_for(theme.js)}/algolia-search.js?v=${stun_env("version")}`)
if is_post()
script(src=`${url_for(theme.js)}/post.js?v=${stun_env("version")}`)
script(src=`${url_for(theme.js)}/post.js?v=${stun_env("version")}`)
if theme.math.enable
- var isHomeHasMath = false;
if is_home()
- page.posts.each(function (post) {
if post.math && !isHomeHasMath
- isHomeHasMath = true
- })
if !is_tag() && !is_category() && !is_archive()
if isHomeHasMath || (theme.math.per_page || page.math)
if theme.math.engine == 'mathjax'
include ./mathjax.pug
else if theme.math.engine == 'katex'
include ./katex.pug
link(href=theme.math.katex.cdn rel="stylesheet" type="text/css")
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 async)
if theme.math.katex.copy_tex.copy_tex_css
link(href=theme.math.katex.copy_tex.copy_tex_css rel="stylesheet" type="text/css")
script(type="text/x-mathjax-config").
var mathjaxMhchem = '';
if (!!'!{theme.math.mathjax.mhchem}') {
mathjaxMhchem = '!{theme.math.mathjax.mhchem}'
MathJax.Ajax.config.path['mhchem'] = mathjaxMhchem;
}
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
processEscapes: true,
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
},
TeX: {
extensions: [mathjaxMhchem],
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(type="text/x-mathjax-config").
MathJax.Hub.Queue(function() {
var all = MathJax.Hub.getAllJax(), i;
for (i = 0; i < all.length; i++) {
document.getElementById(all[i].inputID + '-Frame').parentNode.className += ' has-jax';
}
});
script(src=theme.math.mathjax.cdn async)
......@@ -2,6 +2,7 @@ $(document).ready(function () {
// The previous distance from the page to the top.
var prevScrollTop = 0;
addContainerToTable();
// Initial run.
headerNavScroll();
backToTop();
......@@ -101,4 +102,10 @@ $(document).ready(function () {
$('#back-top').css('display', 'none');
}
}
// Add a container outside the tables to make it scroll when needed.
function addContainerToTable () {
var $wrapper = $('<div style="overflow: auto"></div>');
$('table').wrap($wrapper);
}
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册