feat: added filename extension support for more x-codeSamples languages (#1382)

This commit is contained in:
Shahed Nasser
2024-01-05 13:50:57 +02:00
committed by GitHub
parent 7c7198d72e
commit 147ef98b9e
3 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
"@redocly/cli": patch
---
Added filename extension support for more `x-codeSamples` languages.

View File

@@ -295,6 +295,24 @@ describe('langToExt', () => {
['javascript', '.js'],
['js', '.js'],
['python', '.py'],
['c', '.c'],
['c++', '.cpp'],
['coffeescript', '.litcoffee'],
['dart', '.dart'],
['elixir', '.ex'],
['go', '.go'],
['groovy', '.groovy'],
['java', '.java'],
['kotlin', '.kt'],
['objective-c', '.m'],
['perl', '.pl'],
['powershell', '.ps1'],
['ruby', '.rb'],
['rust', '.rs'],
['scala', '.sc'],
['swift', '.swift'],
['typescript', '.ts'],
['tsx', '.tsx'],
])('should infer file extension from lang - %s', (lang, expected) => {
expect(langToExt(lang)).toBe(expected);
});

View File

@@ -146,6 +146,24 @@ export function langToExt(lang: string) {
javascript: '.js',
js: '.js',
python: '.py',
c: '.c',
'c++': '.cpp',
coffeescript: '.litcoffee',
dart: '.dart',
elixir: '.ex',
go: '.go',
groovy: '.groovy',
java: '.java',
kotlin: '.kt',
'objective-c': '.m',
perl: '.pl',
powershell: '.ps1',
ruby: '.rb',
rust: '.rs',
scala: '.sc',
swift: '.swift',
typescript: '.ts',
tsx: '.tsx',
};
return langObj[lang.toLowerCase()];
}