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

咨询是否支持mathjax #33

Open
dongzl opened this issue Nov 21, 2019 · 10 comments
Open

咨询是否支持mathjax #33

dongzl opened this issue Nov 21, 2019 · 10 comments

Comments

@dongzl
Copy link

dongzl commented Nov 21, 2019

您好,我使用您提供的模板搭建了hexo博客,感谢您的分享。

最近我要在博客中集成使用mathjax插件,一直无法生效,网上查阅各种资料还是不能好用,请问这套模板支持mathjax吗?谢谢

@sanonz
Copy link
Owner

sanonz commented Nov 21, 2019

目前是没有相关功能的,之前想过加上,因为懒一直还没开始动手。

@dongzl
Copy link
Author

dongzl commented Nov 22, 2019

目前是没有相关功能的,之前想过加上,因为懒一直还没开始动手。

作者支持你,感谢你的无私分享,期待早一天能实现这个功能!

@dongzl
Copy link
Author

dongzl commented Nov 22, 2019

如果要修改支持的话,您建议怎么修改吗?

现在也有这种hexo 插件,不过我不太清楚要支持怎么修改,请指导一下,谢谢

https://github.com/phoenixcw/hexo-renderer-mathjax

https://ranmaosong.github.io/2017/11/29/hexo-support-mathjax/

@sanonz
Copy link
Owner

sanonz commented Nov 22, 2019

我研究了下,以下操作不涉及对主题的修改

一、安装 hexo-math 插件

$ npm install hexo-math

二、增加站点配置:_config.yam

math:
  engine: 'mathjax'
  mathjax:
    src: 'https://cdn.bootcss.com/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
    config:
      tex2jax:
        inlineMath:
          - - '$'
            - '$'
          - - '\\('
            - '\\)'
        processEscapes: true
      TeX:
        equationNumbers:
          autoNumber: 'AMS'

三、添加测试文章

---
title: Test MathJax
---

$$ \sqrt{2} $$

四、查看效果

$ hexo server

打开测试文章,如果不出意外将会看到一个根号二。

@sanonz
Copy link
Owner

sanonz commented Nov 22, 2019

你试下可以不,没问题的话我把这个加到 README.md 小提示里边

@dongzl
Copy link
Author

dongzl commented Nov 22, 2019

感谢您的反馈,我测试了一下,没达到效果 $$ \sqrt{2} $$ 原样输出了

image

我的配置是:
package.json:

{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "hexo": {
    "version": "3.8.0"
  },
  "dependencies": {
    "hexo": "^3.8.0",
    "hexo-asset-image": "git+https://github.com/CodeFalling/hexo-asset-image.git",
    "hexo-deployer-git": "^1.0.0",
    "hexo-filter-flowchart": "^1.0.4",
    "hexo-filter-mermaid-diagrams": "^1.0.5",
    "hexo-generator-archive": "^0.1.5",
    "hexo-generator-category": "^0.1.3",
    "hexo-generator-index": "^0.2.1",
    "hexo-generator-tag": "^0.2.0",
    "hexo-inject": "^1.0.0",
    "hexo-math": "^3.0.4",
    "hexo-renderer-ejs": "^0.3.1",
    "hexo-renderer-less": "^1.0.0",
    "hexo-renderer-marked": "^2.0.0",
    "hexo-renderer-stylus": "^0.3.3",
    "hexo-server": "^0.3.3",
    "hexo-tag-plantuml": "^1.0.0"
  }
}

themes/concise/_config.yml

math:
  engine: 'mathjax'
  mathjax:
    src: 'https://cdn.bootcss.com/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
    config:
      tex2jax:
        inlineMath:
          - - '$'
            - '$'
          - - '\\('
            - '\\)'
        processEscapes: true
      TeX:
        equationNumbers:
          autoNumber: 'AMS'

我再执行hexo 命令的时候貌似可以看到加载mathjax引擎了:

ZBMAC-0d3e1bb56:source test$ hexo s
INFO  [hexo-math] Using engine 'mathjax'
INFO  Start processing
INFO  Hexo is running at http://localhost:4000 . Press Ctrl+C to stop.

可能还是哪里使用不对导致没生效?您方便再看看吗?

@sanonz
Copy link
Owner

sanonz commented Nov 22, 2019

放到 /_config.yml 站点配置中,不要放到主题的配置 themes/concise/_config.yml

@dongzl
Copy link
Author

dongzl commented Nov 22, 2019

image

OK,可以了,根号二显示了,我试了几个复杂的,也可以显示了,非常非常感谢!

@sanonz
Copy link
Owner

sanonz commented Nov 22, 2019

不客气

@lolifamily
Copy link
Contributor

@sanonz hexo-inject 效率很低,会大幅度降低hexo g的速度,希望主题能够集成mathjax 3配置文件

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

3 participants