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

preview 数学公式解析问题 #714

Closed
ihewro opened this issue Aug 13, 2020 · 0 comments
Closed

preview 数学公式解析问题 #714

ihewro opened this issue Aug 13, 2020 · 0 comments
Assignees
Milestone

Comments

@ihewro
Copy link

ihewro commented Aug 13, 2020

请先看《提问的智慧》,并尝试到黑客派搜寻资料解决问题。


描述问题

下载的官网的demo里面有一个完整示例:https://vditor.b3log.org/demo/preview.html

也就是preview.html 文件。配置修改了数学公式的引擎,其他的没有修改:

    const initRender = () => {
        fetch('markdown/zh_CN.md').then(response => response.text()).then(markdown => {
            Vditor.preview(document.getElementById('preview'),
                markdown, {
                    sanitize: false,
                    markdown: {
                        sanitize: false,
                    },
                    speech: {
                        enable: true,
                    },
                    "math": {
                        "engine": "MathJax",
                        "macros": {
                            "bf": "{\\boldsymbol f}",
                            "bu": "{\\boldsymbol u}",
                            "bv": "{\\boldsymbol v}",
                            "bw": "{\\boldsymbol w}"
                        },
                        "inlineDigit": true
                    },
                    anchor: 1,
                    after() {
                        if (window.innerWidth <= 768) {
                            return
                        }
                        const outlineElement = document.getElementById('outline')
                        Vditor.outlineRender(document.getElementById('preview'), outlineElement)
                        if (outlineElement.innerText.trim() !== '') {
                            outlineElement.style.display = 'block'
                            initOutline()
                        }
                    },
                })
        })
    }

zh_cn.md填入的内容如下:

$$
\begin{aligned}
\varphi (72)
&=\varphi (2^{3}\times 3^{2})\\
&=2^{3-1}(2-1)\times 3^{2-1}(3-1)\\
&=2^{2}\times 1\times 3\times 2\\
&=24
\end{aligned}
$$

打开preview.html,数学公式显示一下马上就消失掉了,但是在编辑器中显示和预览都是正常的,不知道是我的操作原因吗?

最后解析出来的html,data-math是空的:

<div class="vditor-math" data-math=""><mjx-container class="MathJax CtxtMenu_Attached_0" jax="SVG" display="true" tabindex="0" ctxtmenu_counter="1"><svg xmlns="http://www.w3.org/2000/svg" width="0.002ex" height="0" role="img" focusable="false" viewBox="0 0 1 0" preserveAspectRatio="xMidYMid slice" xmlns:xlink="http://www.w3.org/1999/xlink" style="vertical-align: 0px;"><defs></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="math"></g></g></svg></mjx-container></div>

截屏或录像

@Vanessa219 Vanessa219 self-assigned this Aug 14, 2020
@Vanessa219 Vanessa219 added this to the 3.4 milestone Aug 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants