Download app/src/editor-language.mjs from Mike0021/MiniCPM5-2B-WebGPU-Pi-HTTP: direct link, hf CLI and curl.
- Browser
- Download file 1.19 kB
-
https://huggingface.co/spaces/Mike0021/MiniCPM5-2B-WebGPU-Pi-HTTP/resolve/main/app/src/editor-language.mjs
- Command line
-
hf download hf://spaces/Mike0021/MiniCPM5-2B-WebGPU-Pi-HTTP/app/src/editor-language.mjs
-
curl -L -o editor-language.mjs https://huggingface.co/spaces/Mike0021/MiniCPM5-2B-WebGPU-Pi-HTTP/resolve/main/app/src/editor-language.mjs
1.19 kB
| const extensions = { | |
| html: 'markup', htm: 'markup', xml: 'markup', svg: 'markup', vue: 'markup', | |
| css: 'css', js: 'javascript', mjs: 'javascript', cjs: 'javascript', jsx: 'jsx', | |
| ts: 'typescript', mts: 'typescript', cts: 'typescript', tsx: 'tsx', | |
| json: 'json', ipynb: 'json', md: 'markdown', markdown: 'markdown', | |
| py: 'python', pyw: 'python', sh: 'bash', bash: 'bash', zsh: 'bash', | |
| yml: 'yaml', yaml: 'yaml', toml: 'toml', sql: 'sql', csv: 'csv', | |
| c: 'c', h: 'c', cpp: 'cpp', cc: 'cpp', cxx: 'cpp', hpp: 'cpp', | |
| cs: 'csharp', java: 'java', go: 'go', rs: 'rust', diff: 'diff', patch: 'diff', | |
| }; | |
| export function editorLanguage(path = '') { | |
| const name = path.split('/').at(-1).toLowerCase(); | |
| if (/^dockerfile(?:\.|$)/.test(name)) return 'docker'; | |
| if (/^\.(?:bashrc|bash_profile|zshrc|profile)$/.test(name)) return 'bash'; | |
| return extensions[name.split('.').at(-1)] ?? null; | |
| } | |
| // Bound both tokenization and the amount of highlighted DOM on the main thread. | |
| export function canHighlight(text) { | |
| if (text.length > 200_000) return false; | |
| let lines = 1; | |
| for (let i = 0; i < text.length; i++) if (text.charCodeAt(i) === 10 && ++lines > 5000) return false; | |
| return true; | |
| } | |