We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5437096 commit 7f49f36Copy full SHA for 7f49f36
1 file changed
utils/get_lang.py
@@ -0,0 +1,22 @@
1
+import os
2
+
3
4
+# this will read the file extension and return the correct langague
5
+def get_lexer_for_file(file_path):
6
+ _, ext = os.path.splitext(file_path)
7
8
+ if ext == ".rb":
9
+ return "ruby"
10
11
+ elif ext == ".py":
12
+ from lexers.python.pythonlexer import PythonLexer
13
+ return "python"
14
15
+ elif ext == ".js":
16
+ return "javascript"
17
18
+ elif ext == ".go":
19
+ return "go"
20
21
+ else:
22
+ raise ValueError(f"Unsupported file extension: {ext}")
0 commit comments