MCPcopy Create free account
hub / github.com/Yorick-Ryu/deep-share / normalizeCodeLanguage

Function normalizeCodeLanguage

scripts/injectGptButton.js:196–209  ·  view source on GitHub ↗
(language)

Source from the content-addressed store, hash-verified

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];

Callers 1

getCodeBlockLanguageFunction · 0.85

Calls 1

testMethod · 0.45

Tested by

no test coverage detected