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

能够解析['\(', '\)'], ['\[', '\]']包围的公式吗 #436

Open
jiabochao opened this issue Oct 15, 2024 · 6 comments
Open

能够解析['\(', '\)'], ['\[', '\]']包围的公式吗 #436

jiabochao opened this issue Oct 15, 2024 · 6 comments

Comments

@jiabochao
Copy link

哈喽,想请教一下,如果公式使用小括号和中括号样式的可以支持解析吗,目前发现设置了配置后不生效

MathJax = {
        loader: { load: ['[tex]/ams'] },
        tex: {
          packages: { '[+]': ['ams'] },
          tags: 'ams',
          inlineMath: [
            ['$', '$'],
            ['\$', '\$'],
            ['\(', '\)'],
            ['\\(', '\\)'],
          ], // ["$","$"],["\$","\$"],["\(","\)"],["\\(","\\)"]
          displayMath: [
            ['$$', '$$'],
            ['\[', '\]'],
          ],
        },
        svg: { fontCache: 'none' },
      }

md/index.html

Line 89 in 876a313

MathJax = {

@YangFong
Copy link
Member

需要补充描述,提供示例。

@jiabochao
Copy link
Author

这种不是以$$包围的,而是使用\[ \]包围的公式,可以支持配置公式的起始符号来支持解析吗

\[f'(x_0) = \lim_{\Delta x \to 0} \frac{f(x_0 + \Delta x) - f(x_0)}{\Delta x}\]

@YangFong
Copy link
Member

我不大了解 Latex,你这段公式,不能够将前后的 \[\] 去掉吗,像下面这样:

$$
f'(x_0) = \lim_{\Delta x \to 0} \frac{f(x_0 + \Delta x) - f(x_0)}{\Delta x}
$$

$$ f'(x_0) = \lim_{\Delta x \to 0} \frac{f(x_0 + \Delta x) - f(x_0)}{\Delta x} $$

我看后者的渲染效果也还可以。

@jiabochao
Copy link
Author

目的是支持多种,类似这个配置:https://docs.mathjax.org/en/latest/input/tex/delimiters.html

image

@YangFong
Copy link
Member

那你得看这个文件:https://github.com/doocs/md/blob/main/src/utils/MDKatex.js

我们是先匹配 Markdown 语法,生成标记,再由 MathJax 做渲染,前者匹配规则没有变,那么后者也没法生效。

@jiabochao
Copy link
Author

那你得看这个文件:https://github.com/doocs/md/blob/main/src/utils/MDKatex.js

我们是先匹配 Markdown 语法,生成标记,再由 MathJax 做渲染,前者匹配规则没有变,那么后者也没法生效。

@YangFong 好的,感谢,我看一下

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