Skip to content

Commit 8da90d4

Browse files
committed
fix fences lang
1 parent 789746c commit 8da90d4

File tree

2 files changed

+84
-86
lines changed

2 files changed

+84
-86
lines changed

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"regexp"
99
"strings"
1010

11-
"github.com/spf13/cobra"
1211
u "github.com/rostrovsky/sourceprompt/pkg/utils"
12+
"github.com/spf13/cobra"
1313
)
1414

1515
const DEFAULT_PROMPT = `You will be provided with a markdown text (under the "---" separator) containing the contents of a codebase. Each code snippet will be enclosed in code fences, along with the corresponding file name. Your task is to analyze the codebase and gain a comprehensive understanding of its structure, functionality, and key features.
@@ -34,7 +34,7 @@ Your analysis should be thorough, insightful, and aimed at enabling AI agents to
3434
`
3535

3636
const (
37-
version = "1.0.3"
37+
version = "1.0.4"
3838
)
3939

4040
var (

pkg/utils/utils.go

Lines changed: 82 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -50,87 +50,87 @@ func IsMarkdown(filename string) bool {
5050
}
5151

5252
func DetectLanguage(path string) string {
53-
filename := filepath.Base(path)
54-
ext := strings.ToLower(filepath.Ext(filename))
55-
56-
switch ext {
57-
case ".go", ".templ":
58-
return "go"
59-
case ".py":
60-
return "python"
61-
case ".js":
62-
return "javascript"
63-
case ".ts":
64-
return "typescript"
65-
case ".java":
66-
return "java"
67-
case ".c", ".h":
68-
return "c"
69-
case ".cpp", ".cxx", ".cc", ".hpp":
70-
return "cpp"
71-
case ".cs":
72-
return "csharp"
73-
case ".rb":
74-
return "ruby"
75-
case ".php":
76-
return "php"
77-
case ".swift":
78-
return "swift"
79-
case ".kt", ".kts":
80-
return "kotlin"
81-
case ".rs":
82-
return "rust"
83-
case ".html", ".htm", ".gohtml":
84-
return "html"
85-
case ".css":
86-
return "css"
87-
case ".sql":
88-
return "sql"
89-
case ".sh":
90-
return "bash"
91-
case ".pl":
92-
return "perl"
93-
case ".r":
94-
return "r"
95-
case ".m":
96-
return "objectivec" // This could also be MATLAB
97-
case ".vb":
98-
return "vbnet"
99-
case ".scala":
100-
return "scala"
101-
case ".lua":
102-
return "lua"
103-
case ".groovy":
104-
return "groovy"
105-
case ".dart":
106-
return "dart"
107-
case ".md", ".markdown":
108-
return "markdown"
109-
case ".json":
110-
return "json"
111-
case ".xml":
112-
return "xml"
113-
case ".yaml", ".yml":
114-
return "yaml"
115-
case ".tex":
116-
return "tex"
117-
case ".dockerfile", ".df":
118-
return "dockerfile"
119-
case ".ps1":
120-
return "powershell"
121-
case ".scss":
122-
return "scss"
123-
case ".toml":
124-
return "toml"
125-
case ".zig":
126-
return "zig"
127-
case ".nim":
128-
return "nim"
129-
case ".hs":
130-
return "haskell"
131-
default:
132-
return ""
133-
}
53+
filename := filepath.Base(path)
54+
ext := strings.ToLower(filepath.Ext(filename))
55+
56+
switch ext {
57+
case ".go", ".templ":
58+
return "go"
59+
case ".py":
60+
return "python"
61+
case ".js":
62+
return "javascript"
63+
case ".ts":
64+
return "typescript"
65+
case ".java":
66+
return "java"
67+
case ".c", ".h":
68+
return "c"
69+
case ".cpp", ".cxx", ".cc", ".hpp":
70+
return "cpp"
71+
case ".cs":
72+
return "csharp"
73+
case ".rb":
74+
return "ruby"
75+
case ".php":
76+
return "php"
77+
case ".swift":
78+
return "swift"
79+
case ".kt", ".kts":
80+
return "kotlin"
81+
case ".rs":
82+
return "rust"
83+
case ".html", ".htm", ".gohtml":
84+
return "html"
85+
case ".css":
86+
return "css"
87+
case ".sql":
88+
return "sql"
89+
case ".sh":
90+
return "bash"
91+
case ".pl":
92+
return "perl"
93+
case ".r":
94+
return "r"
95+
case ".m":
96+
return "objectivec" // This could also be MATLAB
97+
case ".vb":
98+
return "vbnet"
99+
case ".scala":
100+
return "scala"
101+
case ".lua":
102+
return "lua"
103+
case ".groovy":
104+
return "groovy"
105+
case ".dart":
106+
return "dart"
107+
case ".md", ".markdown":
108+
return "markdown"
109+
case ".json":
110+
return "json"
111+
case ".xml":
112+
return "xml"
113+
case ".yaml", ".yml":
114+
return "yaml"
115+
case ".tex":
116+
return "tex"
117+
case ".dockerfile", ".df":
118+
return "dockerfile"
119+
case ".ps1":
120+
return "powershell"
121+
case ".scss":
122+
return "scss"
123+
case ".toml":
124+
return "toml"
125+
case ".zig":
126+
return "zig"
127+
case ".nim":
128+
return "nim"
129+
case ".hs":
130+
return "haskell"
131+
default:
132+
return ""
133+
}
134134
}
135135

136136
func ProcessPath(path string, prefixToRemove string, include *regexp.Regexp, exclude *regexp.Regexp, stringBuilder *strings.Builder) error {
@@ -193,10 +193,8 @@ func ProcessPath(path string, prefixToRemove string, include *regexp.Regexp, exc
193193
fences = "````"
194194
}
195195

196-
fences += DetectLanguage(filePath)
197-
198196
stringBuilder.WriteString("`" + filePath + "`\n\n")
199-
stringBuilder.WriteString(fences + "\n")
197+
stringBuilder.WriteString(fences + DetectLanguage(filePath) + "\n")
200198
stringBuilder.Write(content)
201199
if content[len(content)-1] != '\n' {
202200
stringBuilder.WriteString("\n")

0 commit comments

Comments
 (0)