mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-19 14:43:05 -03:00
changes in the API, ready to version 2
This commit is contained in:
@ -8,11 +8,11 @@ import (
|
||||
"regexp"
|
||||
)
|
||||
|
||||
type languageMatcher func ([]byte) (string, bool)
|
||||
type languageMatcher func ([]byte) []string
|
||||
|
||||
var contentMatchers = map[string]languageMatcher{
|
||||
{{ range $index, $disambiguator := . -}}
|
||||
{{ printf "%q" $disambiguator.Extension }}: func(i []byte) (string, bool) {
|
||||
{{ printf "%q" $disambiguator.Extension }}: func(i []byte) []string {
|
||||
{{ range $i, $language := $disambiguator.Languages -}}
|
||||
|
||||
{{- if not (avoidLanguage $language) }}
|
||||
@ -20,14 +20,14 @@ var contentMatchers = map[string]languageMatcher{
|
||||
{{- 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 {{ printf "%q" $language.Language }}, true
|
||||
return []string{ {{- printf "%q" $language.Language -}} }
|
||||
}
|
||||
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end}}
|
||||
|
||||
return {{ returnLanguage $disambiguator.Languages }}, {{ safeLanguage $disambiguator.Languages }}
|
||||
return {{ returnLanguages $disambiguator.Languages | returnStringSlice }}
|
||||
},
|
||||
{{ end -}}
|
||||
}
|
||||
|
Reference in New Issue
Block a user