mirror of
https://github.com/rwinkhart/go-highlite.git
synced 2026-09-05 08:27:19 -04:00
Initial commit
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
package highlight
|
||||
|
||||
import "bytes"
|
||||
|
||||
func DetectFiletype(defs []*Def, filename string, fileSrc []byte) string {
|
||||
firstLine := bytes.Split(fileSrc, []byte("\n"))[0]
|
||||
|
||||
for _, d := range defs {
|
||||
if d.ftdetect[0].Match([]byte(filename)) {
|
||||
return d.ft
|
||||
}
|
||||
if d.ftdetect[1].Match(firstLine) {
|
||||
return d.ft
|
||||
}
|
||||
}
|
||||
|
||||
return "Unknown"
|
||||
}
|
||||
Reference in New Issue
Block a user