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:和Halo2.7以及KaTex2.0插件工作时inline公式显示异常 #31

Closed
psc1453 opened this issue Jul 11, 2023 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@psc1453
Copy link

psc1453 commented Jul 11, 2023

是什么 Halo 版本出现了此问题?

2.7

使用的 Dream 版本是多少?

1.0.3

在线博客地址

https://pscpeng.xyz:4433/archives/demo

BUG 内容

首先我使用 Halo 2.7 并按照 KaTex 2.0 插件 Git Repository 的使用说明设置完成,然后使用 StackEdit 1.0.0 编辑器做了以下demo:
截屏2023-07-12 03 57 44
并在发布时开启了 KaTex 支持:
截屏2023-07-12 03 57 55
此时在编辑器右上方预览按钮内预览内容,一切正常:
截屏2023-07-12 03 58 21
但是在第一次从外部进入文章时,公式无法渲染:
截屏2023-07-12 03 58 38
刷新一次后即可正常显示:
截屏2023-07-12 03 58 48
此后再刷新大概率inline公式会变成块公式:
截屏2023-07-12 03 59 39
希望能够解决这个bug,真的很喜欢您制作的主题。

相关 Console 日志输出

# 这是由自带主题Earth正确解析并渲染的:
<p>Here is a demo <span class="katex--inline"><span class="katex"><span class="katex-mathml"><math
                    xmlns="http://www.w3.org/1998/Math/MathML">
                    <semantics>
                        <mrow>
                            <mi>α</mi>
                            <mo>=</mo>
                            <mi>β</mi>
                        </mrow>
                        <annotation encoding="application/x-tex">\alpha=\beta</annotation>
                    </semantics>
                </math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut"
                        style="height: 0.4306em;"></span><span style="margin-right: 0.0037em;"
                        class="mord mathnormal">α</span><span class="mspace"
                        style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace"
                        style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut"
                        style="height: 0.8889em; vertical-align: -0.1944em;"></span><span
                        style="margin-right: 0.0528em;" class="mord mathnormal">β</span></span></span></span></span> and
    <span class="katex--inline"><span class="katex"><span class="katex-mathml"><math
                    xmlns="http://www.w3.org/1998/Math/MathML">
                    <semantics>
                        <mrow>
                            <mi>Z</mi>
                            <mo>=</mo>
                            <mn>0</mn>
                        </mrow>
                        <annotation encoding="application/x-tex">Z=0</annotation>
                    </semantics>
                </math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut"
                        style="height: 0.6833em;"></span><span style="margin-right: 0.0715em;"
                        class="mord mathnormal">Z</span><span class="mspace"
                        style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace"
                        style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut"
                        style="height: 0.6444em;"></span><span class="mord">0</span></span></span></span></span>
</p>


# 这是Dream主题未能解析并渲染时的:
<div data-id="ea0d0c76-47a8-4a0a-b01e-afadf9be0890" data-target="Post" class="main-content article">
    <link rel="stylesheet" href="/plugins/plugin-katex/assets/static/katex.min.css">

    <script>
        document.addEventListener("DOMContentLoaded", function () {
            const postBody = document.body
            const renderMath = (selector, displayMode) => {
                const els = postBody.querySelectorAll(selector)
                els.forEach((el) => {
                    katex.render(el.innerText, el, { displayMode })
                })
            }
            if (postBody) {
                renderMath(".katex--inline,math-inline", false);
                renderMath(".katex--display,math-display", true);
            }
        });
    </script>

    <p>Here is a demo <span class="katex--inline">\alpha=\beta</span> and <span class="katex--inline">Z=0</span></p>
    <p>Another:<br>
        <span class="katex--display">
            e^{\pi i}=-1
        </span>
    </p>
</div>


# 这是Dream主题将inline解析成block的:
<p>Here is a demo <span class="katex--inline"><span class="katex"><span class="katex-mathml"><math
                    xmlns="http://www.w3.org/1998/Math/MathML">
                    <semantics>
                        <mrow>
                            <mi>α</mi>
                            <mo>=</mo>
                            <mi>β</mi>
                        </mrow>
                        <annotation encoding="application/x-tex">\alpha=\beta</annotation>
                    </semantics>
                </math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut"
                        style="height: 0.4306em;"></span><span style="margin-right: 0.0037em;"
                        class="mord mathnormal">α</span><span class="mspace"
                        style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace"
                        style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut"
                        style="height: 0.8889em; vertical-align: -0.1944em;"></span><span
                        style="margin-right: 0.0528em;" class="mord mathnormal">β</span></span></span></span></span> and
    <span class="katex--inline"><span class="katex"><span class="katex-mathml"><math
                    xmlns="http://www.w3.org/1998/Math/MathML">
                    <semantics>
                        <mrow>
                            <mi>Z</mi>
                            <mo>=</mo>
                            <mn>0</mn>
                        </mrow>
                        <annotation encoding="application/x-tex">Z=0</annotation>
                    </semantics>
                </math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut"
                        style="height: 0.6833em;"></span><span style="margin-right: 0.0715em;"
                        class="mord mathnormal">Z</span><span class="mspace"
                        style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace"
                        style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut"
                        style="height: 0.6444em;"></span><span class="mord">0</span></span></span></span></span></p>

附加信息

No response

@psc1453 psc1453 added the bug Something isn't working label Jul 11, 2023
@nineya
Copy link
Owner

nineya commented Jul 12, 2023

dream会优化自带的KaTex功能,别用KaTex2.0插件了,和pjax功能不兼容

@psc1453 psc1453 closed this as completed Jul 17, 2023
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