mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
fix(coding-agent): highlight dart, nix, and groovy files in read/write views
This commit is contained in:
parent
bb36171aac
commit
7084eec358
2 changed files with 19 additions and 1 deletions
|
|
@ -969,6 +969,10 @@ export function getLanguageFromPath(filePath: string): string | undefined {
|
|||
java: "java",
|
||||
kt: "kotlin",
|
||||
swift: "swift",
|
||||
dart: "dart",
|
||||
groovy: "groovy",
|
||||
gradle: "groovy",
|
||||
nix: "nix",
|
||||
c: "c",
|
||||
h: "c",
|
||||
cpp: "cpp",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
import { resetCapabilitiesCache, setCapabilities } from "@earendil-works/pi-tui";
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import { getMarkdownTheme, highlightCode, initTheme, theme } from "../src/modes/interactive/theme/theme.ts";
|
||||
import {
|
||||
getLanguageFromPath,
|
||||
getMarkdownTheme,
|
||||
highlightCode,
|
||||
initTheme,
|
||||
theme,
|
||||
} from "../src/modes/interactive/theme/theme.ts";
|
||||
import {
|
||||
highlight,
|
||||
loadAllHighlightLanguages,
|
||||
|
|
@ -41,6 +47,14 @@ describe("syntax highlight renderer", () => {
|
|||
expect(supportsLanguage("ada")).toBe(true);
|
||||
});
|
||||
|
||||
it("maps file extensions of eagerly loaded languages to their language", () => {
|
||||
expect(getLanguageFromPath("lib/main.dart")).toBe("dart");
|
||||
expect(getLanguageFromPath("flake.nix")).toBe("nix");
|
||||
expect(getLanguageFromPath("script.groovy")).toBe("groovy");
|
||||
expect(getLanguageFromPath("build.gradle")).toBe("groovy");
|
||||
expect(getLanguageFromPath("src/Main.kt")).toBe("kotlin");
|
||||
});
|
||||
|
||||
it("renders highlighted spans with the provided theme", () => {
|
||||
const rendered = renderHighlightedHtml('<span class="hljs-keyword">const</span> value', {
|
||||
keyword: (text) => `[keyword:${text}]`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue