mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-11-10 21:42:22 +00:00
39 lines
1.1 KiB
Cheetah
39 lines
1.1 KiB
Cheetah
package slinguist
|
|
|
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
|
// Extracted from github/linguist commit: {{ getCommit }}
|
|
|
|
import (
|
|
"regexp"
|
|
)
|
|
|
|
type languageMatcher func ([]byte) []string
|
|
|
|
var contentMatchers = map[string]languageMatcher{
|
|
{{ range $index, $disambiguator := . -}}
|
|
{{ printf "%q" $disambiguator.Extension }}: func(i []byte) []string {
|
|
{{ range $i, $language := $disambiguator.Languages -}}
|
|
|
|
{{- if not (avoidLanguage $language) }}
|
|
{{- if gt (len $language.Heuristics) 0 }}
|
|
{{- if gt $i 0 }} else {{ end -}}
|
|
if {{- range $j, $heuristic := $language.Heuristics }} {{ $heuristic.Name }}.Match(i)
|
|
{{- if lt $j (len $language.LogicRelations) }} {{index $language.LogicRelations $j}} {{- end -}} {{ end }} {
|
|
return []string{ {{- printf "%q" $language.Language -}} }
|
|
}
|
|
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end}}
|
|
|
|
return {{ returnLanguages $disambiguator.Languages | returnStringSlice }}
|
|
},
|
|
{{ end -}}
|
|
}
|
|
|
|
var (
|
|
{{ range $index, $heuristic := getAllHeuristics . -}}
|
|
{{ $heuristic.Name }} = regexp.MustCompile(`{{ $heuristic.Regexp }}`)
|
|
{{ end -}}
|
|
) |