Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
66d07bb2a5 | |||
28035a8513 | |||
98ff7de56a | |||
280c69586f | |||
|
68115abd81 |
22
.github/workflows/npm-publish.yml
vendored
22
.github/workflows/npm-publish.yml
vendored
@ -15,18 +15,12 @@ jobs:
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
|
||||
publish-npm:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
registry-url: https://registry.npmjs.org/
|
||||
- run: npm publish
|
||||
registry-url: https://registry.npmjs.org
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Build
|
||||
run: npm run build
|
||||
- name: Publish package to npm
|
||||
run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
||||
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
|
||||
|
@ -5,7 +5,7 @@ English丨[简体中文](README_zh-CN.md)
|
||||
|
||||
A hexo plugin to use [Shiki](https://github.com/shikijs/shiki) as code block highlighter.
|
||||
|
||||
Hexo v7.0.0+ is required.
|
||||
[Hexo](https://github.com/hexojs/hexo) v7.0.0+ is required.
|
||||
|
||||
## Features
|
||||
- Use [Shiki](https://github.com/shikijs/shiki) to render code blocks, and the format is similar to Hexo's default code highlighting (so you don't need to make significant changes to the theme you are currently using).
|
||||
@ -90,7 +90,8 @@ See [Dual Themes](https://shiki.style/guide/dual-themes) for how to switch betwe
|
||||
You can also specify some languages individually in `original_lang_name` to not convert or only convert them:
|
||||
```yaml
|
||||
original_lang_name:
|
||||
# Set to true to exclude the languages listed in `langs`, otherwise only convert the languages in `langs`.
|
||||
# Set to true to exclude the languages listed in `langs`,
|
||||
# otherwise only convert the languages in `langs`.
|
||||
exclude: true
|
||||
# Must be an array
|
||||
langs:
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
一个使用 [Shiki](https://github.com/shikijs/shiki) 作为代码块高亮器的 Hexo 插件。
|
||||
|
||||
需要 Hexo v7.0.0+。
|
||||
需要 [Hexo](https://github.com/hexojs/hexo) v7.0.0+。
|
||||
|
||||
## 功能
|
||||
- 使用 [Shiki](https://github.com/shikijs/shiki) 渲染代码块,且与 Hexo 默认的代码高亮渲染的格式相似(因此你不需要对你现在使用的主题做很大的修改)。
|
||||
|
@ -4,6 +4,10 @@ import { promises as fs } from 'fs';
|
||||
await build({
|
||||
entryPoints: ['src/main.ts'],
|
||||
bundle: true,
|
||||
external:[
|
||||
'hexo-util',
|
||||
'hexo'
|
||||
],
|
||||
outdir: 'dist',
|
||||
platform: 'node',
|
||||
sourcemap: false,
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hexo-highlighter-shiki",
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.2",
|
||||
"description": "A package for Hexo which use Shiki to render code highlight.",
|
||||
"main": "dist/index.js",
|
||||
"files": [
|
||||
@ -36,6 +36,7 @@
|
||||
"typescript": "^5.6.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"hexo": "^7.0.0"
|
||||
"hexo": "^7.0.0",
|
||||
"hexo-util": "^3.3.0"
|
||||
}
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ export async function init(hexo: Hexo) {
|
||||
for (const extra_theme of [].concat(config.additional.themes)) {
|
||||
additional_themes.push(JSON.parse(readFileSync(extra_theme, "utf8")));
|
||||
}
|
||||
// 处理主题
|
||||
const themes = additional_themes.concat(
|
||||
(typeof config.theme === "string" ? [config.theme] : Object.values(config.theme)).filter(
|
||||
(theme) => theme in bundledThemes
|
||||
@ -151,7 +152,7 @@ export async function init(hexo: Hexo) {
|
||||
};
|
||||
};
|
||||
try {
|
||||
if (config.theme === "string")
|
||||
if (typeof config.theme === "string")
|
||||
pre = highlighter.codeToHtml(code, {
|
||||
lang,
|
||||
theme: config.theme,
|
||||
|
Loading…
Reference in New Issue
Block a user