add extension to lang mapping for python and cpp
@@ -18,16 +18,19 @@ function parseCode(lang, code) {
return tokens.map(normalizeToken)
}
-function adjustLang(lang) {
- if (lang === 'csv') {
- return 'clike'
- }
-
- if (lang === 'js') {
- return 'javascript'
+const extensionsMapping = {
+ csv: 'clike',
+ c: 'cpp',
+ h: 'cpp',
+ hpp: 'cpp',
+ cpp: 'cpp',
+ js: 'javascript',
+ py: 'python'
}
- return lang
+function adjustLang(lang) {
+ const extensionBasedLang = extensionsMapping[lang]
+ return extensionBasedLang ? extensionBasedLang : lang
}
function normalizeToken(token) {
