mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-15 12:55:51 +00:00
fix: 修复代码不能在终端高亮的问题
highlight.js v11 result = hljs().highlight(); 已经不存在result.emitter,使用result._emitter替代
This commit is contained in:
@@ -528,19 +528,20 @@ function highlightLine(
|
||||
// hljs throws on unknown language despite ignoreIllegals
|
||||
return [[defaultStyle(theme), code]]
|
||||
}
|
||||
if (!hasRootNode(result.emitter)) {
|
||||
const emitter = result._emitter;
|
||||
if (!hasRootNode(emitter)) {
|
||||
if (!loggedEmitterShapeError) {
|
||||
loggedEmitterShapeError = true
|
||||
logError(
|
||||
new Error(
|
||||
`color-diff: hljs emitter shape mismatch (keys: ${Object.keys(result.emitter).join(',')}). Syntax highlighting disabled.`,
|
||||
`color-diff: hljs emitter shape mismatch (keys: ${Object.keys(emitter).join(',')}). Syntax highlighting disabled.`,
|
||||
),
|
||||
)
|
||||
}
|
||||
return [[defaultStyle(theme), code]]
|
||||
}
|
||||
const blocks: Block[] = []
|
||||
flattenHljs(result.emitter.rootNode, theme, undefined, blocks)
|
||||
flattenHljs(emitter.rootNode, theme, undefined, blocks)
|
||||
return blocks
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user