Coder Social home page Coder Social logo

Katex显示问题 about hexo-theme-next HOT 17 CLOSED

next-theme avatar next-theme commented on July 20, 2024
Katex显示问题

from hexo-theme-next.

Comments (17)

stevenjoezhang avatar stevenjoezhang commented on July 20, 2024 1

嗯,应该是因为 hexo-renderer-markdown-it 所依赖的 @iktakahiro/markdown-it-katex ,直到最新版本才将使用的 KaTeX 版本从 0.10.0 升级为 0.11.1,导致版本不匹配。这个插件也有两年没更新了,可能需要寻找替代品。
iktakahiro/markdown-it-katex@5238dd1

from hexo-theme-next.

welcome avatar welcome commented on July 20, 2024

Thanks for opening this issue, maintainers will get back to you as soon as possible!

from hexo-theme-next.

issue-label-bot avatar issue-label-bot commented on July 20, 2024

Issue-Label Bot is automatically applying the label Question to this issue, with a confidence of 0.63. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

from hexo-theme-next.

stevenjoezhang avatar stevenjoezhang commented on July 20, 2024

设置没有问题。如果 hexo-renderer-markdown-it-plus 是最近安装的,执行一下 hexo clean 试试。

from hexo-theme-next.

Philchieh avatar Philchieh commented on July 20, 2024

感谢您的回复,我尝试hexo clean后仍不能解决问题

from hexo-theme-next.

stevenjoezhang avatar stevenjoezhang commented on July 20, 2024

是否方便提供一下安装的全部 Hexo 插件(在博客根目录下执行 npm ls --depth 0)。可能是与其它的插件冲突导致的问题,我可以帮忙测试一下。

from hexo-theme-next.

Philchieh avatar Philchieh commented on July 20, 2024

如下所示,十分感谢
$ npm ls --depth 0
[email protected] D:\Philchieh's Blog
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]

from hexo-theme-next.

stevenjoezhang avatar stevenjoezhang commented on July 20, 2024

试试这样:

npm uninstall hexo-renderer-marked
hexo clean

我待会把文档更新一下,这几个插件的使用描述有些不清楚

from hexo-theme-next.

Philchieh avatar Philchieh commented on July 20, 2024

您好,按照您的操作后已经能够显示KaTex公式,然而公式显示十分诡异,请您打开以下网站以得知我的情况
https://philchieh.github.io/2020/08/12/BSGS%20%E7%AE%97%E6%B3%95%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/

from hexo-theme-next.

stevenjoezhang avatar stevenjoezhang commented on July 20, 2024

您好,可能是由于字体原因,在不同浏览器上显示有差异

截屏2020-08-17 下午12 27 45

from hexo-theme-next.

Philchieh avatar Philchieh commented on July 20, 2024

我在我的浏览器上也是这个样子,但是正常的Katex应该与Mathjax的效果一致,如下图
捕获

from hexo-theme-next.

Philchieh avatar Philchieh commented on July 20, 2024

请问是主题的问题亦或是Katex的问题?

from hexo-theme-next.

stevenjoezhang avatar stevenjoezhang commented on July 20, 2024

KaTeX 的渲染分为两步:

  1. hexo-renderer-markdown-it-plus 插件用于预处理,例如将 $\frac{\pi^2}{6}$ 转为
<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mfrac><msup><mi> π</mi><mn>2</mn></msup><mn>6</mn></mfrac></mrow><annotation encoding="application/x-tex">\frac{\pi^2}{6}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.36292em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.01792em;"><span style="top:-2.6550000000000002em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">6</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathdefault mtight" style="margin-right:0.03588em;">π</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8913142857142857em;"><span style="top:-2.931em;margin-right:0.07142857142857144em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>
  1. 而 NexT 负责加载 katex.min.css,为上面的这一段 HTML 添加样式。

从您提供的页面来看,第二步加载的 CSS 没问题,因此不是 NexT 的问题。

我自己一直用的是 MathJax,对 KaTeX 不熟。个人感觉这很有可能与 Markdown Renderer 有关,可以根据文档换用 hexo-renderer-markdown-it 插件试试: https://theme-next.js.org/docs/third-party-services/math-equations#Render-Engines

from hexo-theme-next.

Philchieh avatar Philchieh commented on July 20, 2024

意思是使用后者,也就是hexo-renderer-markdown-it with markdown-it-katex plugin对吗

from hexo-theme-next.

Philchieh avatar Philchieh commented on July 20, 2024

您好,我找到问题了,在layout third-party math 路径下的katex.njk中cdn.jsdelivr.net/npm/katex@0 改为cdn.jsdelivr.net/npm/[email protected]即可。

from hexo-theme-next.

Philchieh avatar Philchieh commented on July 20, 2024

感谢回答,我先关闭了

from hexo-theme-next.

github-actions avatar github-actions commented on July 20, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. It is possible issue was solved or at least outdated. Feel free to open new for related bugs.

from hexo-theme-next.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.