Closed leeyiding closed 1 year ago
能否将这个内容复制出来?我复现下试试看
这个直接在chat.lobehub.com测试的,应该让它随便输出一段代码都能复现
好像是 Python 的高亮失效了
@arvinxx https://github.com/lobehub/lobe-ui/blob/master/src/hooks/useHighlight.ts 没加 python 🤔 这块感觉要改成动态引入方案比较好
@canisminor1990 怎么做动态引入?识别到某个语法然后自动加载?
我建议 python 可以内置掉,其他的再看看?
@canisminor1990 怎么做动态引入?识别到某个语法然后自动加载?
好像有个动态 es6 方案
const shiki = await getHighlighterCore({
themes: [
// instead of strings, you need to pass the imported module
nord,
// or a dynamic import if you want to do chunk splitting
import('shikiji/themes/vitesse-light.mjs')
],
langs: [
import('shikiji/langs/javascript.mjs'),
// shikiji will try to interop the module with the default export
() => import('shikiji/langs/css.mjs'),
// or a getter that returns custom grammar
async () => JSON.parse(await fs.readFile('my-grammar.json', 'utf-8'))
],
loadWasm: getWasmInlined
})
我建议 python 可以内置掉,其他的再看看?
fixed https://github.com/lobehub/lobe-ui/commit/0d6de6e6c657cdf9e084822370914f406f474bee
@canisminor1990 怎么做动态引入?识别到某个语法然后自动加载?
好像有个动态 es6 方案
这个动态方案就要是外部传进来不存在的 lang 时,重新初始化 shiki 这样来实现了
💻 系统环境 | Operating System
Windows
🌐 浏览器 | Browser
Chrome
🐛 问题描述 | Bug Description
代码块渲染异常,所有代码都挤到一行了
🚦 期望结果 | Expected Behavior
No response
📷 复现步骤 | Recurrence Steps
No response
📝 补充信息 | Additional Information
No response