Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

数学公式支持坏掉了 #33

Open
plus2047 opened this issue Mar 20, 2023 · 3 comments
Open

数学公式支持坏掉了 #33

plus2047 opened this issue Mar 20, 2023 · 3 comments

Comments

@plus2047
Copy link

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

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

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

@plus2047
Copy link
Author

我升级到 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>

@TMaize
Copy link
Owner

TMaize commented Mar 21, 2023

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

2023-03-21_122117

@plus2047
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants