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.
32 lines
698 B
TypeScript
32 lines
698 B
TypeScript
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
|
|
}
|