hexo博客替换更高级的Markdown渲染器

一直在用 Hexo 写博客,感觉也挺方便的,但是用着用着就发现 hexo 的默认 markdown 渲染器太低级了,很多东西不支持。于是想着扩展下 markdown 渲染器,在网上搜了下解决办法,于是发现了hexo-renderer-markdown-it,安装使用方法就不介绍了在 github 上都有,今天主要介绍了扩展了那些功能,方便查阅直接使用。以下就是我安装使用的扩展

- markdown-it-attrs
- markdown-it-deflist
- markdown-it-emoji
- markdown-it-footnote
- markdown-it-ins
- markdown-it-mark
- markdown-it-sub
- markdown-it-sup
- markdown-it-checkbox
- markdown-it-container

markdown-it-attrs

使用花括号将类、id 标识符和属性添加到标记中

# header {.style-me}

paragraph {data-toggle=modal}
<h1 class="style-me">header</h1>
<p data-toggle="modal">paragraph</p>

更多功能可查阅markdown-it-attrs

markdown-it-deflist

为 markdown 添加 dl 标签支持

First Term
: This is the definition of the first term.

Second Term
: This is one definition of the second term.
: This is another definition of the second term.
<dl>
  <dt>First Term</dt>
  <dd>This is the definition of the first term.</dd>
  <dt>Second Term</dt>
  <dd>This is one definition of the second term.</dd>
  <dd>This is another definition of the second term.</dd>
</dl>

markdown-it-emoji

这个就比较强大了,添加 emoji 支持。在文章中插入表情符号一般可以从输入法中直接插入,也可以写 emoji 简码

常用的 emoji 简码

:joy: 😂
:smile: 😄
:laughing: 😆
:sunglasses: 😎

更多简码可参考Streamlit emoji shortcodes

markdown-it-footnote

增加脚注支持,可以用于特殊词汇

Here is a footnote reference,[1] and another.[2]

Subsequent paragraphs are indented to show that they belong to the previous footnote.

markdown-it-mark

标记

markdown-it-sub

增加上标支持

X^2^

X2

markdown-it-sup

增加下标支持

H~2~0

H20

markdown-it-checkbox

增加多选支持

- [ ] sdf
- [x] sdfdd

markdown-it-container

提示
这是一个提示

注意
这是一个警告

警告
这是一个危险信号

成功
这是一个成功信号

markdown-it-ins

下划线
df

总结

以上列出的插件除了 markdown-it-container 和 markdown-it-ins 貌似 markdown 都以支持 😅
如果功能不够还可以自行安装,具体安装过程可参考hexo-renderer-markdown-it


  1. Here is the footnote. ↩︎

  2. Here’s one with multiple blocks. ↩︎