jan/web/utils/codeLanguageExtension.ts
Faisal Amir e196aefcd3
feat: new UI code block and Enable copying of code blocks or plain text mid-stream (#4010)
* feat: improvement ui codeblock

* chore: update ui code block

* chore: finalize ui code block and latex

* chore: fix jest testing and cleanup unused deps
2024-11-14 14:46:35 +07:00

35 lines
719 B
TypeScript

// Utility function using switch-case for extension to language mapping
export function getLanguageFromExtension(extension: string): string {
switch (extension.toLowerCase()) {
case 'ts':
case 'tsx':
return 'typescript'
case 'js':
case 'jsx':
return 'javascript'
case 'py':
return 'python'
case 'java':
return 'java'
case 'rb':
return 'ruby'
case 'cs':
return 'csharp'
case 'md':
return 'markdown'
case 'yaml':
case 'yml':
return 'yaml'
case 'sh':
return 'bash'
case 'rs':
return 'rust'
case 'kt':
return 'kotlin'
case 'swift':
return 'swift'
default:
return extension
}
}