Skip to content

Commit

Permalink
fix get lexer by name typos
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhamlett committed Aug 22, 2023
1 parent 0f35591 commit 5f14b77
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/language/chroma/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

func init() { // nolint: gochecknoinits
lexers.Get("HTHML").SetAnalyser(func(text string) float32 {
lexers.Get("HTML").SetAnalyser(func(text string) float32 {
if matched, _ := doctype.MatchString(text, "html"); matched {
return 0.5
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/make.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
var makefileAnalyserVariableRe = regexp.MustCompile(`\$\([A-Z_]+\)`)

func init() { // nolint: gochecknoinits
lexers.Get("Base Makefile").SetAnalyser(func(text string) float32 {
lexers.Get("Makefile").SetAnalyser(func(text string) float32 {
// Many makefiles have $(BIG_CAPS) style variables.
if makefileAnalyserVariableRe.MatchString(text) {
return 0.1
Expand Down
4 changes: 2 additions & 2 deletions pkg/language/chroma/make_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (

"github.com/alecthomas/assert"
"github.com/alecthomas/chroma"
"github.com/alecthomas/chroma/lexers/m"
"github.com/alecthomas/chroma/v2/lexers"
)

func TestMakefile_AnalyseText(t *testing.T) {
data, err := os.ReadFile("testdata/makefile")
assert.NoError(t, err)

analyser, ok := m.Makefile.(chroma.Analyser)
analyser, ok := lexers.Get("Makefile").(chroma.Analyser)
assert.True(t, ok)

assert.Equal(t, float32(0.1), analyser.AnalyseText(string(data)))
Expand Down
8 changes: 8 additions & 0 deletions pkg/language/chroma/testdata/brainfuck_greater_less.bf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
>>>++[
<++++++++[
<[<++>-]>>[>>]+>>+[
-[->>+<<<[<[<<]<+>]>[>[>>]]]
<[>>[-]]>[>[-<<]>[<+<]]+<<
]<[>+<-]>>-
]<.[-]>>
]
1 change: 1 addition & 0 deletions pkg/language/chroma/testdata/brainfuck_minus.bf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[-]
1 change: 1 addition & 0 deletions pkg/language/chroma/testdata/brainfuck_plus_minus.bf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
>+>+>+>+>+>+>+[->[>]+[->[>]+>+>+[<]+<]+<]+++++++[>+++++++++++>+<<-]>+.----.>++.

0 comments on commit 5f14b77

Please sign in to comment.