hexo-使用渲染器-hexo-renderer-markdown-it

People who are crazy enough to think they can change the world, are the ones who do.
Apple Computers

hexo-renderer-markdown-it 的速度要比 hexo-renderer-marked 原装插件要快,而且功能更多

首先进入博客目录,卸载hexo默认的 marked 渲染器,安装 markdown-it 渲染器,运行的命令如:

1
2
$ npm un hexo-renderer-marked --save
$ npm i hexo-renderer-markdown-it --save

标准配置说明

这里有一份标准配置:

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
# Markdown-it config
## Docs: https://github.com/celsomiranda/hexo-renderer-markdown-it/wiki
## cn_Docs: https://markdown-it.docschina.org/api/MarkdownIt.html#markdownit-new
markdown:
render:
# false。设成 true 来启用在源码中(支持) HTML 标签。注意!这是不安全的!你可能需要额外的消毒剂(sanitizer)来组织来自 XSS 的输出。最好是通过插件来扩展特性,而不是启用 HTML。
html: true
# 设成 true 来给闭合的单个标签(<br />)添加 '/'。只有完全兼容 CommonMark 模式时才需要这样做。实际上你只需要 HTML 输出。
xhtmlOut: false
# 设成 true 来转化段落里的 \n 成 <br>
breaks: true
# 设成 true 来自动转化像 URL 的文本成链接。
linkify: true
# 设成 true 来启用某些语言中性的替换以及引号的美化(智能引号)。
typographer: true
# String 或 Array 类型。在 typographer 启用和支持智能引号时,进行双引号 + 单引号对替换。 比方说,
# 你可以支持 '«»„“' 给俄罗斯人使用, '„“‚‘' 给德国人使用。
# 还有 ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] 给法国人使用(包括 nbsp)。
quotes: "“”‘’"
plugins:
- markdown-it-abbr
- markdown-it-footnote
- markdown-it-ins
- markdown-it-sub
- markdown-it-sup
anchors:
level: 1
collisionSuffix: "v"
# If `true`, creates an anchor tag with a permalink besides the heading.
# 如果为“true”,则在标题旁边创建一个带有永久链接的定位标记。
permalink: false
permalinkClass: header-anchor
# The symbol used to make the permalink
# 用于生成永久链接的符号
permalinkSymbol: ˃

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
- level:生成 Heading ID 的标题等级
- collisionSuffix:Heading ID 重复时,数字的后缀
- permalink:'true',则创建一个锚标记,除标题外还有一个固定链接
- permalinkClass:用于固定链接锚标记的样式
- permalinkSymbol:用于固定链接标记的符号

若想更改 `permalinkSymbol` 里面符号,可以参考:[permalinkSymbol](https://graphemica.com/unicode/characters)

注:如果不想显示 `permalinkSymbol` 的符号,可以改 `permalink: true` 为 `permalink: false` 即可

- html:定义文档中的HTML内容是否应转义或传递给最终结果。
html: true # 不转义 HTML 内容
html: false # 转义 HTML 内容,使标签作为文本输出

- xhtmlOut:定义解析器是否将导出完全兼容XHTML的标记。
xhtmlOut: true # 必须使用完全的 XHTML 代码,换行必须为 <br/>
xhtmlOut: false # 不必必使用完全的 XHTML 代码,换行可以为 <br>

- breaks:使源文件中的换行符被解析为<br>标记。每次按Enter键都会创建换行符。
breaks: true # 每次会车换行相当于一个 <br/> 标签
breaks: false # Pa每次会车换行会被忽略

- linkify:解析器能够将直接粘贴到文本中的链接内联。
linkify: true # 类似链接的文本,作为链接输出
linkify: false # 类似链接的文本,依然作为文本输出

- typographer:可以替换常见的排版元素。
typographer: true # 替换常见的排版元素
typographer: false # 不替换常见的排版元素

- quotes:单引号、双引号如何被替换
quotes: '“”‘’' # 'single'、"double" 变成 ‘single’、“double”
quotes: '«»“”' # 'single'、"double" 变成 “single”、«single»

使用markdown-it-emoji

hexo-配置使用emoji

使用wiki links插件

hexo-url-link-wikilink-obsidian-解决方案