[fix] multi renderer support, resolve #476 (#481)

This commit is contained in:
纸鹿/Zhilu 2024-05-31 20:32:15 +08:00 committed by GitHub
parent 366f3e6e26
commit 5f9389806b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 26 deletions

View File

@ -528,11 +528,9 @@ plugins:
# https://github.com/KaTeX/KaTeX # https://github.com/KaTeX/KaTeX
# 使用 hexo-renderer-markdown-it-plus 作为公式渲染器npm uninstall hexo-renderer-marked --save npm install hexo-renderer-markdown-it-plus --save # 使用 hexo-renderer-markdown-it-plus 作为公式渲染器npm uninstall hexo-renderer-marked --save npm install hexo-renderer-markdown-it-plus --save
katex: katex:
enable: #true # 可以在特定文章的 front-matter 中设置 katex: true 来开启,也可以在这里设置全局开启 enable: #true # hexo-renderer-markdown-it-plus 默认开启 katex此选项仅用于引入样式
inject: | inject: |
<link rel="stylesheet" href="https://gcore.jsdelivr.net/npm/katex@0.16.4/dist/katex.min.css" integrity="sha384-vKruj+a13U8yHIkAyGgK1J3ArTLzrFGBbBc0tDp4ad/EyewESeXE/Iv67Aj8gKZ0" crossorigin="anonymous"> <link rel="stylesheet" href="https://gcore.jsdelivr.net/npm/katex@0.16.4/dist/katex.min.css" integrity="sha384-vKruj+a13U8yHIkAyGgK1J3ArTLzrFGBbBc0tDp4ad/EyewESeXE/Iv67Aj8gKZ0" crossorigin="anonymous">
<script defer src="https://gcore.jsdelivr.net/npm/katex@0.16.4/dist/katex.min.js" integrity="sha384-PwRUT/YqbnEjkZO0zZxNqcxACrXe+j766U2amXcgMg5457rve2Y7I6ZJSm2A0mS4" crossorigin="anonymous"></script>
<script defer src="https://gcore.jsdelivr.net/npm/katex@0.16.4/dist/contrib/auto-render.min.js" integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05" crossorigin="anonymous"onload="renderMathInElement(document.body);"></script>
# MathJax # MathJax
# 需在Markdown文件开头加入mathjax: true # 需在Markdown文件开头加入mathjax: true

View File

@ -9,7 +9,7 @@
'use strict' 'use strict'
module.exports = ctx => function(args) { module.exports = ctx => function (args) {
var el = '' var el = ''
args = ctx.args.map(args, ['el', 'icon', 'prefix', 'suffix'], ['text']) args = ctx.args.map(args, ['el', 'icon', 'prefix', 'suffix'], ['text'])
if (!args.el) { if (!args.el) {
@ -43,7 +43,6 @@ module.exports = ctx => function(args) {
if (args.el.includes('h')) { if (args.el.includes('h')) {
el += '<div' + ' class="tag-plugin quot">' el += '<div' + ' class="tag-plugin quot">'
el += '<' + args.el + ' class="content" id="' + args.text + '"' + type + '>' el += '<' + args.el + ' class="content" id="' + args.text + '"' + type + '>'
el += '<a href="#' + args.text + '" class="headerlink" title="' + args.text + '"></a>'
el += content() el += content()
el += '</' + args.el + '>' el += '</' + args.el + '>'
el += '</div>' el += '</div>'

View File

@ -30,7 +30,7 @@
margin-left: 0.5em margin-left: 0.5em
h1,h2,h3,h4,h5,h6 h1,h2,h3,h4,h5,h6
text-align: center text-align: center
a.headerlink >a:first-child
display: none display: none
h2 h2
margin: 2em 0 1.5em margin: 2em 0 1.5em
@ -71,19 +71,14 @@
h1,h2,h3,h4,h5,h6 h1,h2,h3,h4,h5,h6
color: var(--text) color: var(--text)
line-height: 1.8 line-height: 1.8
blockquote, .tag-plugin >a:first-child
h2,h3,h4,h5,h6
margin-top: 0.25em
margin-bottom: 0.25em
a.headerlink
background: $color-theme background: $color-theme
border-radius: 2px border-radius: 2px
margin-right: 8px margin-right: 8px
trans1 background trans1 background
a.headerlink:hover &:hover
background: $color-hover background: $color-hover
a.headerlink:before &:before
content: '' content: ''
color: white color: white
font-weight: 700 font-weight: 700
@ -91,9 +86,14 @@
font-size: $fs-12 font-size: $fs-12
h2 h2
font-weight: 500 font-weight: 500
a.headerlink:before >a:first-child:before
content: ':' content: ':'
blockquote, .tag-plugin
h2,h3,h4,h5,h6
margin-top: 0.25em
margin-bottom: 0.25em
.md-text.content:first-child .tag-plugin:first-child .md-text.content:first-child .tag-plugin:first-child
margin-top: 0 margin-top: 0

View File

@ -11,8 +11,6 @@
border-bottom: none border-bottom: none
font-weight: 700 font-weight: 700
padding: 0 24px padding: 0 24px
a.headerlink
display: none
@media screen and (max-width: $device-mobile) @media screen and (max-width: $device-mobile)
padding: 0 20px padding: 0 20px
line-height: 1.2 line-height: 1.2