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

Support MathJax v3.0 #1314

Merged
merged 13 commits into from
Feb 10, 2020
Merged

Support MathJax v3.0 #1314

merged 13 commits into from
Feb 10, 2020

Conversation

reuixiy
Copy link
Contributor

@reuixiy reuixiy commented Dec 14, 2019

Just an attempt, not sure if it works :)
@welcome
Copy link

welcome bot commented Dec 14, 2019

Thanks so much for opening your first PR here!

@claassistantio
Copy link

claassistantio commented Dec 14, 2019

CLA assistant check
All committers have signed the CLA.

@1v9 1v9 added this to the v7.7.0 milestone Dec 15, 2019
@reuixiy reuixiy changed the title Support MathJax v3.0 WIP: Support MathJax v3.0 Dec 15, 2019
@stevenjoezhang
Copy link
Contributor

stevenjoezhang commented Dec 15, 2019

Thanks for your contribution!

@reuixiy
Copy link
Contributor Author

reuixiy commented Dec 15, 2019

@stevenjoezhang,

It's my pleasure :)

This work should be done and can already be merged now. I have tested with theme-next.org (with pjax also) and it works well if this fix is implemented.

@reuixiy reuixiy changed the title WIP: Support MathJax v3.0 Support MathJax v3.0 Dec 15, 2019
@stevenjoezhang
Copy link
Contributor

stevenjoezhang commented Dec 28, 2019

@reuixiy

The same content renders normally in mathjax2, but mathjax3 will report an error:

TypeError: t.splitText is not a function

Can you help investigate?

https://zhangshuqiao.org/Mathjax2/
https://zhangshuqiao.org/Mathjax3/

米米的博客
上帝说,要有\begin{eqnarray*}\nabla\cdot\vec{E}&=&\frac{\rho}{\epsilon_0}\\\nabla\cdot\vec{B}&=&0\\\nabla\times\vec{E}&=&-\frac{\partial B}{\partial t}\\\nabla\times\vec{B}&=&
米米的博客
上帝说,要有\begin{eqnarray*}\nabla\cdot\vec{E}&=&\frac{\rho}{\epsilon_0}\\\nabla\cdot\vec{B}&=&0\\\nabla\times\vec{E}&=&-\frac{\partial B}{\partial t}\\\nabla\times\vec{B}&=&

@reuixiy
Copy link
Contributor Author

reuixiy commented Dec 28, 2019

Hi @stevenjoezhang,

It seems to be a bug, see mathjax/MathJax#2202

@stevenjoezhang
Copy link
Contributor

stevenjoezhang commented Dec 28, 2019

Maybe we need to wait until the next release of MathJax 3, because this bug often occurs when users use some specific Hexo renderer.

https://github.com/mathjax/MathJax-src/releases

@reuixiy Thanks again for your work!

GitHub
MathJax source code for version 3 and beyond. Contribute to mathjax/MathJax-src development by creating an account on GitHub.

@stevenjoezhang stevenjoezhang removed this from the v7.7.0 milestone Dec 31, 2019
@reuixiy
Copy link
Contributor Author

reuixiy commented Feb 8, 2020

@stevenjoezhang,

MathJax v3.0.1 just released, and this issue has been resolved.

@stevenjoezhang stevenjoezhang added this to the 7.7.2 milestone Feb 8, 2020
@stevenjoezhang
Copy link
Contributor

Thanks for reminding, I will perform some tests, such as the compatibility of mathjax and pjax refresh 🤪

@stevenjoezhang
Copy link
Contributor

stevenjoezhang commented Feb 8, 2020

There are now two issues:

  1. When the width of the inline math in the list element is large, it cannot slide left and right, but causes the entire page to overflow.
Overflow test

- 233333
- $\nabla\cdot\vec{E}=\frac{\rho}{\epsilon_0},\nabla\cdot\vec{E}=\frac{\rho}{\epsilon_0},\nabla\cdot\vec{E}=\frac{\rho}{\epsilon_0},\nabla\cdot\vec{E}=\frac{\rho}{\epsilon_0}$
- 6666

截屏2020-02-08下午1 22 27

  1. Display math will generate an extra <br> causing the line spacing to be too large

截屏2020-02-08下午1 33 11

I have researched their solutions in mathjax2: #1004 #603 , is it possible to port them to mathjax3?

MathJax.Hub.Register.StartupHook ('TeX Jax Ready', function () {})

@reuixiy
Copy link
Contributor Author

reuixiy commented Feb 8, 2020

I see... I'd like to solve these but it's just too difficult for me...

So I submit an issue in MathJax, see mathjax/MathJax#2319

@stevenjoezhang
Copy link
Contributor

jsDelivr CDN is now updated, these two links are the same

截屏2020-02-09下午2 02 53

@reuixiy
Copy link
Contributor Author

reuixiy commented Feb 9, 2020

CDN

My confirmation yesterday found that mathjax@3 was not updated to mathjax@3.0.1. Anyway, I will change it back, since

This takes advantage of the feature of jsdeliver that allows you to get the latest version using the mathjax@3 notation.

https://docs.mathjax.org/en/latest/web/configuration.html#loading-mathjax

options

It's necessary if user uses a plugin that will wrap <script> around the formula. Otherwise, the formula will not be rendered, see mathjax/MathJax#2220. The plugin, such as hexo-renderer-kramed used by theme-next.org.

MathJax.startup.document.state(0);

I followed the Occam's razor principle, and when I tested this page(with pjax on), I found that the formula would still display well when I deleted it. But, correct me if I was wrong.

Two problems

  1. <br>

    Wow, it's really nice if we can solve that just by CSS! I'll commit the CSS code you suggested immediately!

  2. inline overflow

    I saw that you have marked it as resolved and reopened the related issues. Yep, maybe we need a little more coffee to solve this problem...

@stevenjoezhang
Copy link
Contributor

Thank you for your reply. Of course, I think the situation is:

If the car is not broken, do not fix it.

If your tests confirm these functions are normal, then no changes are required. I don't know much about mathjax and can't guarantee that my code is correct. The only problem that needs to be solved now is the inline math overflow in the list element.

@reuixiy
Copy link
Contributor Author

reuixiy commented Feb 9, 2020

The only problem that needs to be solved now is the inline math overflow in the list element.

Yep

@stevenjoezhang stevenjoezhang merged commit 23be73f into theme-next:master Feb 10, 2020
@welcome
Copy link

welcome bot commented Feb 10, 2020

Congrats on merging your first pull request here! 🎉 How awesome!

@reuixiy
Copy link
Contributor Author

reuixiy commented Feb 10, 2020

Wow, awesome!

@asdf2014
Copy link
Member

asdf2014 commented Feb 11, 2020

@reuixiy @stevenjoezhang Hmm... Something went wrong. After using this patch, I cannot render mathjax. The probable cause is that we cannot find //cdn.jsdelivr.net/npm/mathjax@3/es5/input/tex/extensions/AMScd.js, unless replaced by amscd.js. More details:

https://yuzhouwan.com/posts/42737/

宇宙湾
什么是人工智能 人工智能(Artificial Intelligence, AI)亦称机器智能,是指由人工制造出来的系统所表现出来的智能。 — wikipedia.org  从 深蓝到 AlphaZero,人工智能的智力水平、普适性、学习能力 正在以爆炸式地速度快速发展; 从 棋类到 医学,人工智能开始在各类应用领域,都在大展身手; 从 CPU / GPU 到 TPU,人工智能的计算能力正向着无法

@stevenjoezhang
Copy link
Contributor

stevenjoezhang commented Feb 11, 2020

@asdf2014 It seems that jsdelivr is not case sensitive: https://www.jsdelivr.com/package/npm/mathjax?path=es5%2Finput%2Ftex%2Fextensions
I suggest temporarily using other CDN services instead

jsDelivr
A free, fast, and reliable Open Source CDN for npm and GitHub with the largest network and best performance, perfectly suited for production use.

@asdf2014
Copy link
Member

@stevenjoezhang Thanks, I tried cdn.jsdelivr.net and unpkg.com, and neither of them worked. Do you have any other suggestions?

@asdf2014
Copy link
Member

@reuixiy @stevenjoezhang At the moment, I can't find a solution to this problem. Sorry, I have to revert this patch.

@reuixiy
Copy link
Contributor Author

reuixiy commented Feb 12, 2020

@asdf2014,

See mathjax/MathJax-src#335

@Liam0205 Liam0205 mentioned this pull request Feb 12, 2020
17 tasks
@asdf2014
Copy link
Member

@reuixiy Thanks a lot. It works, and by the way I raised up a PR #1379. PTAL.

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

Successfully merging this pull request may close these issues.

5 participants