作者:朱某不爱说话
文章:JOE主题MathJax公式支持
阅读:2446
分类:网络技术
发布:2023-04-10
1.在 functions.php 文件中的全站评论开关前增加以下内容
$JMathJax = new Typecho_Widget_Helper_Form_Element_Select(
'JMathJax',
array(
'on' => '开启(默认)',
'off' => '关闭'
),
'on',
'开启或关闭全站 MathJax 支持',
'介绍:开启后,全站支持 MathJax 公式渲染 <br />
说明:MathJax 是一个 JavaScript 库,用于在网页上显示数学公式 <br />
其他:MathJax 官网 <a target="_blank" href="//www.mathjax.org">www.mathjax.org</a>'
);
$JMathJax->setAttribute('class', 'joe_content joe_global');
$form->addInput($JMathJax->multiMode());
2.在 post.php 文件的head标签中添加以下内容
<?php if ($this->options->JMathJax !== 'off') : ?>
<script>
window.MathJax = {
tex: {
inlineMath: [ ["$", "$"]],
displayMath: [ ["$$","$$"]],
processEscapes: true,
processEnvironments: true
},
options: {
skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
ignoreHtmlClass: 'tex2jax_ignore',
processHtmlClass: 'tex2jax_process'
}
};
</script>
<script src="https://cdn.lhjjjlxays.top/npm/mathjax@3/es5/tex-chtml.js" async></script>
<?php endif; ?>
版权属于:
朱某不爱说话
作品采用:
《
署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)
》许可协议授权