KaTeX hexo-renderer-markdown-it-plus 插件兼容问题
hermitlsr opened this issue · comments
检查清单
问题描述
在使用 katex
时需要更换默认的 markdown
渲染器,即:
使用 hexo-renderer-markdown-it-plus 作为公式渲染器:npm uninstall hexo-renderer-marked --save npm install hexo-renderer-markdown-it-plus --save
更换后会导致文章标题丢失样式:
会由此: <a class="markdownIt-Anchor" href="#1-写在前面"></a>
更换为: <a href="#1-写在前面" class="headerlink" title="1 写在前面"></a>
需要额外兼容
主题里的部分样式绑定了 marked 渲染器所生成的类名,不应该直接更换渲染器,这部分代码逻辑可能需要更新
那现在用 katex (行内公式)的话,也还是要用 hexo-renderer-markdown-it-plus ,只是样式恢复了?还是说不换 renderer 也可以正常使用 katex?
我现在用 hexo-renderer-markdown-it-plus,主题更新到最新,但标题样式还是没有。
需要换 renderer,主题还没发布新版本所以暂时看不到标题样式
好了,需要改一下 hexo-renderer-markdown-it的配置,类似这样:
markdown: # https://github.com/hexojs/hexo-renderer-markdown-it
preset: 'default'
anchors:
permalink: true
permalinkSymbol: ''
PS: 刚又试了一下,如果不更新到 #481,直接通过配置修改一下 <a>
的 class 也能恢复原来的样式:
markdown: # https://github.com/hexojs/hexo-renderer-markdown-it
preset: 'default'
anchors:
permalink: true
permalinkClass: 'headerlink' # 这里修改 <a> 的 class
permalinkSymbol: ''
PPS: 原来我用的是 hexo-renderer-markdown-it,而不是 hexo-renderer-markdown-it-plus -_-
ZhiluBlog pnpm remove hexo-renderer-marked
WARN 3 deprecated subdependencies found: cuid@2.1.8, glob@7.2.3, inflight@1.0.6
Packages: -50
--------------------------------------------------
Progress: resolved 184, reused 183, downloaded 0, added 0, done
dependencies:
- hexo-renderer-marked 6.3.0
Done in 1.2s
ZhiluBlog pnpm i hexo-renderer-markdown-it-plus
WARN 3 deprecated subdependencies found: cuid@2.1.8, glob@7.2.3, inflight@1.0.6
Packages: +20
++++++++++++++++++++
Progress: resolved 204, reused 203, downloaded 0, added 20, done
dependencies:
+ hexo-renderer-markdown-it-plus 1.0.6
Done in 1.9s
ZhiluBlog hexo clean; hexo serve
INFO Validating config
INFO Welcome to Stellar 1.28.1
DOCS https://xaoxuu.com/wiki/stellar/
REPO https://github.com/xaoxuu/hexo-theme-stellar.git
INFO Deleted database.
INFO Validating config
INFO Welcome to Stellar 1.28.1
DOCS https://xaoxuu.com/wiki/stellar/
REPO https://github.com/xaoxuu/hexo-theme-stellar.git
INFO Start processing
(node:24072) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
INFO Hexo is running at http://localhost:4000/ . Press Ctrl+C to stop.
未能复现问题。试试 npm update --save
后执行 hexo clean; hexo serve
。