概述

hexo-renderer-markdown-it 是一个基于 markdown-it 的 Hexo 渲染器,比起默认的渲染插件 hexo-renderer-marked 来说能够提供更多的插件来支持更多的语法,比如上标 / 下标 / 注脚 / Emoji Sheet 等等。根据文档说法,它比默认的渲染器更快,所以在对大量的文章渲染的时候应该会有优势。

安装

卸载 Hexo 自带的 markdown 渲染器:

1
npm un hexo-renderer-marked --save

安装 hexo-renderer-markdown-it

1
npm i hexo-renderer-markdown-it --save

插件配置

默认配置如下(需添加到_config.yml):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# hexo-renderer-markdown-it
## install date:
## Docs: https://github.com/hexojs/hexo-renderer-markdown-it/?tab=readme-ov-file#options
markdown:
preset: 'default'
render:
html: true
xhtmlOut: false
langPrefix: 'language-'
breaks: true
linkify: true
typographer: true
quotes: '“”‘’'
enable_rules:
disable_rules:
plugins:
# 启用内部插件
- markdown-it-abbr
- markdown-it-cjk-breaks
- name: markdown-it-container
options: success
- name: markdown-it-container
options: tips
- name: markdown-it-container
options: warning
- name: markdown-it-container
options: danger
- markdown-it-deflist
- markdown-it-emoji
- markdown-it-footnote
- markdown-it-ins
- markdown-it-mark
- markdown-it-sub
- markdown-it-sup
# 需下载的额外插件
- markdown-it-task-lists
anchors:
level: 2
collisionSuffix: ''
permalink: false
permalinkClass: 'header-anchor'
permalinkSide: 'left'
permalinkSymbol: '¶'
case: 0
separator: '-'
images:
lazyload: false
prepend_root: false
post_asset: false
inline: false # https://markdown-it.github.io/markdown-it/#MarkdownIt.renderInline

内置插件

第三方插件

参考资料


  1. 这是一个注脚。 ↩︎