Skip to content

Commit d6bdd14

Browse files
Stephen Afam-Osemenealecthomas
Stephen Afam-Osemene
authored andcommitted
sort lexers with lower case
1 parent 373b6b7 commit d6bdd14

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Diff for: lexer.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package chroma
22

33
import (
44
"fmt"
5+
"strings"
56
)
67

78
var (
@@ -98,9 +99,11 @@ type Lexer interface {
9899
// Lexers is a slice of lexers sortable by name.
99100
type Lexers []Lexer
100101

101-
func (l Lexers) Len() int { return len(l) }
102-
func (l Lexers) Swap(i, j int) { l[i], l[j] = l[j], l[i] }
103-
func (l Lexers) Less(i, j int) bool { return l[i].Config().Name < l[j].Config().Name }
102+
func (l Lexers) Len() int { return len(l) }
103+
func (l Lexers) Swap(i, j int) { l[i], l[j] = l[j], l[i] }
104+
func (l Lexers) Less(i, j int) bool {
105+
return strings.ToLower(l[i].Config().Name) < strings.ToLower(l[j].Config().Name)
106+
}
104107

105108
// PrioritisedLexers is a slice of lexers sortable by priority.
106109
type PrioritisedLexers []Lexer

0 commit comments

Comments
 (0)