(language)
| 194 | }; |
| 195 | |
| 196 | const normalizeCodeLanguage = (language) => { |
| 197 | const normalized = (language || '').trim().toLowerCase(); |
| 198 | const aliases = { |
| 199 | 'c++': 'cpp', |
| 200 | 'c#': 'csharp', |
| 201 | 'js': 'javascript', |
| 202 | 'ts': 'typescript', |
| 203 | 'shell': 'bash', |
| 204 | 'zsh': 'bash', |
| 205 | }; |
| 206 | |
| 207 | if (aliases[normalized]) return aliases[normalized]; |
| 208 | return /^[a-z0-9_+-]+$/.test(normalized) ? normalized : ''; |
| 209 | }; |
| 210 | |
| 211 | const getCodeBlockLanguage = (preNode, codeNode) => { |
| 212 | const classLanguage = codeNode.className.match(/language-([a-zA-Z0-9_+-]+)/)?.[1]; |
no test coverage detected