Initial commit

This commit is contained in:
Zachary Yedidia
2017-02-12 11:21:27 -05:00
commit 5a939241ee
3 changed files with 325 additions and 0 deletions
+18
View File
@@ -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"
}