feat(notes): render code files with Shikiji syntax highlighting

Non-markdown files opened as stacked notes are now highlighted using
the existing markdown-it-shikiji pipeline (4-backtick fence wrapping)
with a h1 filename heading. Edit controls are hidden for code files.
Adds alloy language grammar and a fileLanguage utility mapping
extensions to Shikiji language IDs.
This commit is contained in:
Julien Calixte
2026-04-27 19:57:15 +02:00
parent 812f393283
commit 9d6f70546e
4 changed files with 329 additions and 5 deletions

31
src/utils/fileLanguage.ts Normal file
View File

@@ -0,0 +1,31 @@
const EXT_TO_LANG: Record<string, string> = {
sh: "bash",
bash: "bash",
js: "javascript",
mjs: "javascript",
cjs: "javascript",
ts: "typescript",
mts: "typescript",
cts: "typescript",
md: "markdown",
mdx: "markdown",
html: "html",
htm: "html",
css: "css",
scss: "css",
json: "json",
jsonc: "json",
als: "alloy"
}
const MARKDOWN_EXTS = new Set(["md", "mdx"])
export function isMarkdownPath(path: string): boolean {
const ext = path.split(".").pop()?.toLowerCase() ?? ""
return MARKDOWN_EXTS.has(ext)
}
export function getFileLanguage(path: string): string | null {
const ext = path.split(".").pop()?.toLowerCase() ?? ""
return EXT_TO_LANG[ext] ?? null
}