diff --git a/modules/highlight/highlight.go b/modules/highlight/highlight.go index 4ee47b7a13..bd6137dc85 100644 --- a/modules/highlight/highlight.go +++ b/modules/highlight/highlight.go @@ -96,7 +96,7 @@ func Code(fileName, language, code string) (output template.HTML, lexerName stri } if lexer == nil { - lexer = lexers.Match(fileName) + lexer = lexers.Match(strings.ToLower(fileName)) if lexer == nil { lexer = lexers.Fallback } @@ -165,7 +165,7 @@ func File(fileName, language string, code []byte) ([]template.HTML, string, erro lexer = lexers.Get(guessLanguage) if lexer == nil { - lexer = lexers.Match(fileName) + lexer = lexers.Match(strings.ToLower(fileName)) if lexer == nil { lexer = lexers.Fallback } diff --git a/modules/highlight/highlight_test.go b/modules/highlight/highlight_test.go index 83d35d93ef..03db4d5090 100644 --- a/modules/highlight/highlight_test.go +++ b/modules/highlight/highlight_test.go @@ -109,6 +109,12 @@ c=2 ), lexerName: "Python", }, + { + name: "DOS.PAS", + code: "", + want: lines(""), + lexerName: "ObjectPascal", + }, } for _, tt := range tests {