extToLang (utils/codeHighlight.ts)

open-webui · src/lib/utils/codeHighlight.ts · typescript · BSD-3-Clause
ui

Utility mapping file extensions to Shiki language IDs and highlighting code snippets.

// Source: https://github.com/open-webui/open-webui | License: BSD-3-Clause | Copyright 2023- Open WebUI Inc. [Created by Timothy Jaeryang Baek]
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Map file extensions to Shiki language identifiers.
 * Only extensions whose Shiki lang id differs from the extension itself need explicit entries.
 */
const EXT_OVERRIDE: Record<string, string> = {
	py: 'python',
	js: 'javascript',
	ts: 'typescript',
	jsx: 'jsx',
	tsx: 'tsx',
	rb: 'ruby',
	rs: 'rust',
	kt: 'kotlin',
	cs: 'csharp',
	fs: 'fsharp',
	sh: 'bash',
	bash: 'bash',
	zsh: 'bash',
	yml: 'yaml',
	md: 'markdown',
	mdx: 'mdx',
	dockerfile: 'dockerfile',
	tf: 'terraform',
	hcl: 'hcl',
	ex: 'elixir',
	exs: 'elixir',
	erl: 'erlang',
	hs: 'haskell',
	ml: 'ocaml',
	mli: 'ocaml',

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key