next-theme / hexo-theme-next

🎉 Elegant and powerful theme for Hexo.
https://theme-next.js.org
Other
2.44k stars 432 forks source link

Mathjax2 not rendering until page refresh #167

Closed silencial closed 3 years ago

silencial commented 3 years ago

Issue Checklist


Expected behavior

Math Equations should be rendered.

Actual behavior

Equations are not rendered when

Equations are rendered when


Go to this blog and open the post with title Mobile Robots on the first page. See that the math is not rendered, then refresh the page to see it works.

Steps to reproduce the behavior

Environment Information

Node.js and NPM Information

v12.19.0
6.14.8

Package dependencies Information

hexo-site@0.0.0 /Users/silencial/Documents/Blog
├── hexo@5.3.0
├── hexo-deployer-git@2.1.0
├── hexo-filter-emoji@2.2.1
├── hexo-filter-nofollow@2.0.2
├── hexo-generator-archive@0.1.5
├── hexo-generator-category@0.1.3
├── hexo-generator-feed@2.2.0
├── hexo-generator-index@0.2.1
├── hexo-generator-searchdb@1.3.3
├── hexo-generator-sitemap@2.1.0
├── hexo-generator-tag@0.2.0
├── hexo-heading-index@1.0.1
├── hexo-renderer-ejs@0.3.1
├── hexo-renderer-pandoc@0.3.0
├── hexo-renderer-stylus@2.0.1
├── hexo-server@0.2.2
├── hexo-symbols-count-time@0.7.1
├── hexo-theme-next@8.1.0
└── npm@7.3.0

Hexo Configuration

NexT Configuration

math:
  every_page: true

  mathjax:
    enable: true

  katex:
    enable: false
    copy_tex: false

vendors:
  mathjax: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/MathJax.js?config=TeX-MML-AM_CHTML

Other Information

welcome[bot] commented 3 years ago

Thanks for opening this issue, maintainers will get back to you as soon as possible!

sli1989 commented 3 years ago

你的demo刷新也无法打开额。

silencial commented 3 years ago

你的demo刷新也无法打开额。

我这边刷新数学公式就出来了呀 😂 你是开的哪一篇文章?

stevenjoezhang commented 3 years ago

NexT only supports MathJax 3. You should update the CDN URL in vendors.

https://github.com/theme-next/hexo-theme-next/pull/1314/files#diff-ecec67b0e1d7e17a83587c6d27b6baaaa133f42482b07bd3685c77f34b62d883L912-R912

See also https://github.com/next-theme/hexo-theme-next/issues/4

截屏2020-12-28 上午11 10 53
silencial commented 3 years ago

抱歉之前确实没找到这个说明。

使用 Mathjax3 是没问题的,但是 Mathjax3 目前还缺少很多 feature,比如 \\ 换行,可以参照 issue。估计很多人还是在使用 Mathjax2?

所以有没有可能继续支持 Mathjax2 呢?

stevenjoezhang commented 3 years ago

如果要使用 Mathjax 2,最简单的方法是使用后端渲染插件 hexo-filter-mathjax,见 https://github.com/next-theme/hexo-filter-mathjax/issues/15#issuecomment-626151993

silencial commented 3 years ago

安装 hexo-filter-mathjax 后和之前行为一样,还是需要刷新后公式才能正常渲染。直接从主页的 Read More 点进去公式不渲染

stevenjoezhang commented 3 years ago

执行 hexo clean 试试

另外需要禁用 NexT 自带的 MathJax

math:
  mathjax:
    enable: false
silencial commented 3 years ago

试了一圈,发现在文章 front-matter 中加入 mathjax: true 后一切正常,否则即使刷新也没有效果。不知道要怎么开启对所有页面都默认支持 mathjax 的选项呢?

已在 hexo 的 _config.yml 中开启,但无效:

mathjax:
  every_page: true
silencial commented 3 years ago

大概明白了,hexo-filter-mathjax@0.2.0 版还不支持 every_page 的选项。看来只能在每篇 post 中加入 mathjax: true

silencial commented 3 years ago

问题还是有点多,比如 numbering equations 也不行了,看来还是得等 MathJax3 支持 😐。 感谢 @stevenjoezhang

github-actions[bot] commented 2 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. It is possible issue was solved or at least outdated. Feel free to open new for related bugs.