Fix/expand chatui code highlighting 扩展 chatui 代码高亮 - #9892
Open
atqiyu wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="dashboard/scripts/build-t2i-shiki-runtime.mjs" line_range="32" />
<code_context>
cts: "typescript",
+ cs: "csharp",
dockerfile: "bash",
+ golang: "go",
+ h: "c",
+ "h++": "cpp",
</code_context>
<issue_to_address>
**issue (broader_impact):** The T2I runtime aliases `golang` to `go`, but `go` is absent from `languageSpecs`, so the generated highlighter contains no Go grammar and its supported-language set excludes `go`. Go and `golang` code blocks therefore fall back to plain text or trigger the rendering fallback instead of being highlighted in the T2I path.
**Triggers:** When a T2I code block uses `go` or `golang`.
**Suggested fix:** Add `["go", "go"]` to `languageSpecs` before generating `shiki_runtime.iife.js`.
```suggestion
["go", "go"],
["javascript", "javascript"],
```
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: dashboard/scripts/build-t2i-shiki-runtime.mjs:32
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation / 更改动机
AstrBot ChatUI 使用精简版 Shiki 代码高亮包,以降低前端资源体积和内存占用。但该精简包缺少 C、C++、Rust、Go 等常用编程语言的语法包,导致对应 Markdown 代码块无法正常进行语法高亮,只显示为单一颜色。
本 PR 扩展精简版 Shiki bundle,使更多常用开发语言能够正常高亮,同时保留未知语言回退为纯文本的行为。
Modifications / 改动点
在 ChatUI 的 Shiki 精简包中加入以下语言:
增加常见语言别名支持,例如:
c++、cc、cxx、hppgolangrscskt、kts支持带附加参数的语言标签,例如
rust:variant。同步更新 T2I Shiki runtime 的语言列表,确保不同渲染路径的行为保持一致。
新增 Shiki 语言归一化和代码高亮自动化测试。
未引入新的第三方依赖。
未改变未知语言回退为纯文本的行为。
This is NOT a breaking change. / 这不是一个破坏性变更。
Screenshots or Test Results / 运行截图或测试结果
已完成以下验证:
新增测试覆盖以下场景:
———
Checklist / 检查清单
If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
My changes have been well-tested, and verification results have been provided above.
/ 我的更改经过了充分测试,并已在上方提供验证结果。
I have ensured that no new dependencies are introduced.
/ 我确保没有引入新的依赖库。
My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
Expand Shiki language support and normalization so common programming-language code blocks render with syntax highlighting across ChatUI rendering paths.
New Features:
Bug Fixes:
Enhancements:
Tests: