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

[Bug Report] MathJax 无法渲染 #880

Open
3 tasks done
xdewx opened this issue Aug 25, 2024 · 6 comments
Open
3 tasks done

[Bug Report] MathJax 无法渲染 #880

xdewx opened this issue Aug 25, 2024 · 6 comments
Labels
🐞bug Something isn't working

Comments

@xdewx
Copy link

xdewx commented Aug 25, 2024

Prerequisites

Describe the Bug

公式无法正常渲染,相关的配置文档也不详细;

 mathBlock: {
    engine: 'MathJax', // katex or MathJax
    src: 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js',
    plugins: true, // Default load plug-in
},
inlineMath: {
    engine: 'MathJax', // katex or MathJax
},

图片

另外经实践发现,根据当前的文档描述,mermaid的异步引入会出错,同样需要使用default解构才可以正常工作

const registerPlugin = async () => {
    const [{ default: CherryMermaidPlugin }, { default: mermaid }] = await Promise.all([
        import('cherry-markdown/src/addons/cherry-code-block-mermaid-plugin'),
        // import('cherry-markdown/src/addons/cherry-code-block-plantuml-plugin'),
        import('mermaid'),
        // import('mathjax/es5/tex-mml-svg'),
    ]);
    console.info(CherryMermaidPlugin, mermaid)
    Cherry.usePlugin(CherryMermaidPlugin, {
        mermaid, // pass in mermaid object
    });
};

Reproduction Steps

No response

System Information

No response

Contributing

None

@xdewx xdewx added the 🐞bug Something isn't working label Aug 25, 2024
@foxfire881
Copy link

配置问题吧,我这里是正常的:

      mathBlock: {
        engine: "MathJax", // katex或MathJax
        src: import.meta.env.BASE_URL + "/mathjax/es5/tex-svg.js",
        plugins: true, // 默认加载插件
      },
      inlineMath: {
        engine: "MathJax", // katex或MathJax
        src: import.meta.env.BASE_URL + "/mathjax/es5/tex-svg.js",
      },
import CherryMermaidPlugin from "cherry-markdown/dist/addons/cherry-code-block-mermaid-plugin";
import mermaid from "mermaid";

Cherry.usePlugin(CherryMermaidPlugin, {
  mermaid,
});

捕获

@xdewx
Copy link
Author

xdewx commented Aug 28, 2024

配置问题吧,我这里是正常的:

      mathBlock: {
        engine: "MathJax", // katex或MathJax
        src: import.meta.env.BASE_URL + "/mathjax/es5/tex-svg.js",
        plugins: true, // 默认加载插件
      },
      inlineMath: {
        engine: "MathJax", // katex或MathJax
        src: import.meta.env.BASE_URL + "/mathjax/es5/tex-svg.js",
      },
import CherryMermaidPlugin from "cherry-markdown/dist/addons/cherry-code-block-mermaid-plugin";
import mermaid from "mermaid";

Cherry.usePlugin(CherryMermaidPlugin, {
  mermaid,
});

捕获

你是指其他配置项可能影响到公式吗?直觉上来说都是独立的不应该呀

另外我是用的最新版本的markdown+mermaid9+echarts4(READMD文档上的版本号)

再者,您可以试下异步import看看mermaid的导入方式是不是如我所说

@foxfire881
Copy link

你是指其他配置项可能影响到公式吗?直觉上来说都是独立的不应该呀
另外我是用的最新版本的markdown+mermaid9+echarts4(READMD文档上的版本号)
再者,您可以试下异步import看看mermaid的导入方式是不是如我所说

我也是最新版本,不过我没有用异步加载耶~ 很早之前在其他项目用过异步加载,感觉问题比较多处理、调试起来都很麻烦,意义也不大,所以后来就不用了,直接copy demo代码就能调通的事就不折腾了。

@foxfire881
Copy link

Prerequisites

Describe the Bug

公式无法正常渲染,相关的配置文档也不详细;

 mathBlock: {
    engine: 'MathJax', // katex or MathJax
    src: 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js',
    plugins: true, // Default load plug-in
},
inlineMath: {
    engine: 'MathJax', // katex or MathJax
},

图片

另外经实践发现,根据当前的文档描述,mermaid的异步引入会出错,同样需要使用default解构才可以正常工作

const registerPlugin = async () => {
    const [{ default: CherryMermaidPlugin }, { default: mermaid }] = await Promise.all([
        import('cherry-markdown/src/addons/cherry-code-block-mermaid-plugin'),
        // import('cherry-markdown/src/addons/cherry-code-block-plantuml-plugin'),
        import('mermaid'),
        // import('mathjax/es5/tex-mml-svg'),
    ]);
    console.info(CherryMermaidPlugin, mermaid)
    Cherry.usePlugin(CherryMermaidPlugin, {
        mermaid, // pass in mermaid object
    });
};

Reproduction Steps

No response

System Information

No response

Contributing

None

又看了一遍你的配置,确实是少了一行,你只配置了Block块级公式的src,Inline行级公式的src没有配置,而你截图里插入的都是行级公式的代码,当然无法解析。

@xdewx
Copy link
Author

xdewx commented Aug 29, 2024

Prerequisites

有块级公式吧,双$中间就是

@xdewx
Copy link
Author

xdewx commented Aug 31, 2024

实测:

  1. 在vite+vue初始化工程下,最简配置下将cherry-markdown版本回退到0.8.45公式渲染就正常了
  2. 在我的复杂工程下,将cherry-markdown版本回退到0.8.40公式也正常渲染
  3. 最新0.8.46在以上工程下都无法正常工作

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants