Skip to content

Commit 755b65a

Browse files
committed
expand default diffs languages
1 parent 659b5dc commit 755b65a

5 files changed

Lines changed: 99 additions & 46 deletions

File tree

docs/tools/diffs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ All fields are optional unless noted.
206206

207207
OpenClaw includes syntax highlighting for common source, config, and documentation languages:
208208

209-
`javascript`, `typescript`, `tsx`, `jsx`, `json`, `markdown`, `yaml`, `css`, `html`, `sh`, `python`, `go`, `rust`, `java`, `c`, `cpp`, `csharp`, `php`, `sql`, and `docker`.
209+
`javascript`, `typescript`, `tsx`, `jsx`, `json`, `markdown`, `yaml`, `css`, `html`, `sh`, `python`, `go`, `rust`, `java`, `c`, `cpp`, `csharp`, `php`, `sql`, `docker`, `ruby`, `swift`, `kotlin`, `r`, `dart`, `lua`, `powershell`, `xml`, and `toml`.
210210

211-
Common aliases such as `js`, `ts`, `bash`, `md`, `yml`, `c++`, and `dockerfile` are normalized to those default languages.
211+
Common aliases such as `js`, `ts`, `bash`, `md`, `yml`, `c++`, `dockerfile`, `rb`, `kt`, and `ps1` are normalized to those default languages.
212212

213213
Install the Diff Viewer Language Pack plugin to highlight other languages:
214214

extensions/diffs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Useful options:
6161
- `expandUnchanged`: expand unchanged sections (per-call option only, not a plugin default key)
6262
- `path`: display name for before and after input
6363
- `lang`: language hint for before/after input; unknown values fall back to plain text
64-
- Default syntax highlighting covers common languages. Install `diffs-language-pack` for the extended language catalog.
64+
- Default syntax highlighting covers common source, config, and documentation languages. Install `diffs-language-pack` for the extended language catalog.
6565
- `title`: explicit viewer title
6666
- `ttlSeconds`: artifact lifetime for viewer and standalone file outputs
6767
- `baseUrl`: override the gateway base URL used in the returned viewer link (origin or origin+base path only; no query/hash)

extensions/diffs/assets/viewer-runtime.js

Lines changed: 41 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extensions/diffs/src/language-hints.test.ts

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,43 @@ describe("filterSupportedLanguageHints", () => {
1616

1717
it("normalizes common aliases to base viewer languages", async () => {
1818
await expect(
19-
filterSupportedLanguageHints(["ts", "c++", "c#", "bash", "dockerfile"]),
20-
).resolves.toEqual(["typescript", "cpp", "csharp", "sh", "docker"]);
19+
filterSupportedLanguageHints(["ts", "c++", "c#", "bash", "dockerfile", "rb", "kt", "ps1"]),
20+
).resolves.toEqual([
21+
"typescript",
22+
"cpp",
23+
"csharp",
24+
"sh",
25+
"docker",
26+
"ruby",
27+
"kotlin",
28+
"powershell",
29+
]);
30+
});
31+
32+
it("keeps mainstream languages in the base viewer without the language pack", async () => {
33+
await expect(
34+
filterSupportedLanguageHints([
35+
"ruby",
36+
"swift",
37+
"kotlin",
38+
"r",
39+
"dart",
40+
"lua",
41+
"powershell",
42+
"xml",
43+
"toml",
44+
]),
45+
).resolves.toEqual([
46+
"ruby",
47+
"swift",
48+
"kotlin",
49+
"r",
50+
"dart",
51+
"lua",
52+
"powershell",
53+
"xml",
54+
"toml",
55+
]);
2156
});
2257

2358
it("drops uncommon languages without the language pack", async () => {

extensions/diffs/src/shiki-curated-languages.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ const csharp = () => import("@shikijs/langs/csharp");
1818
const php = () => import("@shikijs/langs/php");
1919
const sql = () => import("@shikijs/langs/sql");
2020
const docker = () => import("@shikijs/langs/docker");
21+
const ruby = () => import("@shikijs/langs/ruby");
22+
const swift = () => import("@shikijs/langs/swift");
23+
const kotlin = () => import("@shikijs/langs/kotlin");
24+
const r = () => import("@shikijs/langs/r");
25+
const dart = () => import("@shikijs/langs/dart");
26+
const lua = () => import("@shikijs/langs/lua");
27+
const powershell = () => import("@shikijs/langs/powershell");
28+
const xml = () => import("@shikijs/langs/xml");
29+
const toml = () => import("@shikijs/langs/toml");
2130

2231
type CuratedLanguageInfo = {
2332
readonly id: string;
@@ -47,6 +56,15 @@ export const bundledLanguagesInfo = [
4756
{ id: "php", name: "PHP", import: php },
4857
{ id: "sql", name: "SQL", import: sql },
4958
{ id: "docker", name: "Docker", aliases: ["dockerfile"], import: docker },
59+
{ id: "ruby", name: "Ruby", aliases: ["rb"], import: ruby },
60+
{ id: "swift", name: "Swift", import: swift },
61+
{ id: "kotlin", name: "Kotlin", aliases: ["kt", "kts"], import: kotlin },
62+
{ id: "r", name: "R", import: r },
63+
{ id: "dart", name: "Dart", import: dart },
64+
{ id: "lua", name: "Lua", import: lua },
65+
{ id: "powershell", name: "PowerShell", aliases: ["ps", "ps1"], import: powershell },
66+
{ id: "xml", name: "XML", import: xml },
67+
{ id: "toml", name: "TOML", import: toml },
5068
] as const satisfies readonly CuratedLanguageInfo[];
5169

5270
export const bundledLanguagesBase = Object.fromEntries(

0 commit comments

Comments
 (0)