A hexo plugin to use Shiki 式 as code block highlighter, which is accurate and powerful.
Hexo v7.0.0+ is required, due to highlighter api and top-level await support.
- Accurate and powerful syntax highlighting.
- Line marker support. (This highlighter only adds
.marked
class to the line, you need to style it yourself.) - Support code block with caption. (You may need to style it yourself.)
First, install this package.
pnpm add hexo-shiki-highlighter
Then, switch the highlighter to shiki
in your _config.yml
.
syntax_highlighter: "shiki"
Finally, configure the options for shiki in your _config.yml
.
shiki:
theme: "dark-plus"
strip_indent: true # Strip the leading indent of the code block (default: true, just like the official highlighter)
You can use the normal backtick code block to highlight your code, but if you want more control, use the codeblock
tag, just like the official highlighter (e.g. highlight.js
or prismjs
).
{% codeblock pyproject.toml lang:toml mark:2 %}
[tool.poetry]
package-mode = false
{% endcodeblock %}