(code: string, hint?: string)
| 18 | // --------------------------------------------------------------------------- |
| 19 | |
| 20 | function detectLanguage(code: string, hint?: string): string { |
| 21 | if (hint) return resolveLang(hint) ?? "json"; |
| 22 | const trimmed = code.trimStart(); |
| 23 | if (trimmed.startsWith("{") || trimmed.startsWith("[")) return "json"; |
| 24 | if (trimmed.startsWith("<")) return "xml"; |
| 25 | if (trimmed.startsWith("---")) return "yaml"; |
| 26 | return "json"; |
| 27 | } |
| 28 | |
| 29 | // --------------------------------------------------------------------------- |
| 30 | // Icons |
no test coverage detected