Resolve a Prism language from the source response or file path.
(source: NodeSourceResponse)
| 136 | |
| 137 | /** Resolve a Prism language from the source response or file path. */ |
| 138 | function detectLanguage(source: NodeSourceResponse): string { |
| 139 | if (source.language) { |
| 140 | const lower = source.language.toLowerCase(); |
| 141 | // Already a prism name or in our map |
| 142 | return EXT_TO_LANG[lower] ?? lower; |
| 143 | } |
| 144 | const ext = source.path.split('.').pop()?.toLowerCase() ?? ''; |
| 145 | return EXT_TO_LANG[ext] ?? 'plaintext'; |
| 146 | } |
| 147 | |
| 148 | export interface NodeEdge { |
| 149 | label: string; |