tmaize-blog icon indicating copy to clipboard operation
tmaize-blog copied to clipboard

数学公式支持坏掉了

Open plus2047 opened this issue 2 years ago • 3 comments

样例页面: https://blog.tmaize.net/posts/2015/01/01/%E4%B8%BB%E9%A2%98%E9%A2%84%E8%A7%88.html

数学公式虽然可以显示,但渲染有问题,正常情况下应该是斜体。并且有数学公式的页面字体和行间距也会出问题。

我试着自己修,但没修好。。

plus2047 avatar Mar 20 '23 08:03 plus2047

我升级到 MathJax 3 了,你看你想要不,我可以找时间给你个 MR,

<script>
  window.MathJax = {
    tex: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      displayMath: [ ['$$','$$'], ["\\[","\\]"] ]
    },
    startup: {
      pageReady: async function () {
        await MathJax.startup.defaultPageReady();

        const mathArray = document.querySelectorAll('script[type="math/tex; mode=display"]');
        mathArray.forEach(function (el) {
          const math = el.textContent;
          const displayMath = '\\[' + math + '\\]';
          const node = document.createElement('span');
          node.innerHTML = displayMath;
          el.parentNode.replaceChild(node, el);
        });

        return MathJax.typesetPromise();
      }
    }
  };
</script>

<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

plus2047 avatar Mar 21 '23 02:03 plus2047

我这里看到的是这样的,斜体好像是正常的,段落间距是有点问题

2023-03-21_122117

TMaize avatar Mar 21 '23 04:03 TMaize

貌似是 MathJax 2 在比较新版的浏览器里有时候会出问题了,升级到 MathJax 3 就好了。你如果需要我可以提个 MR

plus2047 avatar Mar 23 '23 13:03 plus2047