公式支持 - Katex (#94)

- 使用 hexo-renderer-markdown-it-plus 作为渲染器
- 支持多种复杂的公式
- 目前尚在更新维护
This commit is contained in:
偊由 2022-06-10 23:30:59 +08:00 committed by GitHub
parent 645dbad4b8
commit 841614f784
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -310,6 +310,15 @@ plugins:
enable: false enable: false
cdn: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS-MML_HTMLorMML cdn: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS-MML_HTMLorMML
# Katex - The fastest math typesetting library for the web
# https://katex.org/docs/autorender.html
# https://github.com/KaTeX/KaTeX
# 使用 hexo-renderer-markdown-it-plus 作为公式渲染器npm uninstall hexo-renderer-marked --save npm install hexo-renderer-markdown-it-plus --save
katex:
enable: false
min_css: <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/katex.min.css" integrity="sha384-Xi8rHCmBmhbuyyhbI88391ZKP2dmfnOl4rT9ZfRI7mLTdk1wblIUnrIq35nqwEvC" crossorigin="anonymous">
min_js: <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/katex.min.js" integrity="sha384-X/XCfMm41VSsqRNQgDerQczD69XqmjOOOwYQvr/uuC+j4OPoNhVgjdGFwhvN02Ja" crossorigin="anonymous"></script>
auto_render_min_js: <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/contrib/auto-render.min.js" integrity="sha384-+XBljXPPiv+OzfbB3cVmLHf4hdUFHlWNZN5spNQ7rmHTXpd7WvJum6fIACpNNfIR" crossorigin="anonymous"onload="renderMathInElement(document.body);"></script>
style: style:
darkmode: auto # auto / always / false darkmode: auto # auto / always / false

View File

@ -86,6 +86,12 @@ function og_args() {
<%- css(theme.style.codeblock.highlightjs_theme) %> <%- css(theme.style.codeblock.highlightjs_theme) %>
<% } %> <% } %>
<% if (theme.plugins.katex && theme.plugins.katex.enable) { %>
<%- theme.plugins.katex.min_css %>
<%- theme.plugins.katex.min_js %>
<%- theme.plugins.katex.auto_render_min_js %>
<% } %>
<% if (config.inject && config.inject.head){ %> <% if (config.inject && config.inject.head){ %>
<% (config.inject.head||[]).forEach(function(item){ %> <% (config.inject.head||[]).forEach(function(item){ %>