diff --git a/modules/highlight/highlight.go b/modules/highlight/highlight.go index ba3ba479d5..71318c0f69 100644 --- a/modules/highlight/highlight.go +++ b/modules/highlight/highlight.go @@ -103,7 +103,12 @@ func Code(fileName, language, code string) (output template.HTML, lexerName stri cache.Add(fileName, lexer) } - return CodeFromLexer(lexer, code), formatLexerName(lexer.Config().Name) + lexerName = formatLexerName(lexer.Config().Name) + if lexerName == "Bash" { + lexerName = "Shell" + } + + return CodeFromLexer(lexer, code), lexerName } // CodeFromLexer returns a HTML version of code string with chroma syntax highlighting classes @@ -183,6 +188,9 @@ func File(fileName, language string, code []byte) ([]template.HTML, string, erro } lexerName := formatLexerName(lexer.Config().Name) + if lexerName == "Bash" { + lexerName = "Shell" + } iterator, err := lexer.Tokenise(nil, string(code)) if err != nil { diff --git a/modules/highlight/highlight_test.go b/modules/highlight/highlight_test.go index ed5d190764..96af9ecacb 100644 --- a/modules/highlight/highlight_test.go +++ b/modules/highlight/highlight_test.go @@ -55,6 +55,12 @@ func TestFile(t *testing.T) { want: lines(""), lexerName: "YAML", }, + { + name: "empty.sh", + code: "", + want: lines(""), + lexerName: "Shell", + }, { name: "tags.txt", code: "<>", diff --git a/tests/integration/linguist_test.go b/tests/integration/linguist_test.go index 06ff1bd22f..01ffae5069 100644 --- a/tests/integration/linguist_test.go +++ b/tests/integration/linguist_test.go @@ -242,13 +242,13 @@ func TestLinguistSupport(t *testing.T) { t.Run("file source view", func(t *testing.T) { defer tests.PrintCurrentTest(t)() - assertFileLanguage(t, "/src/branch/main/foo.c?display=source", "Bash") + assertFileLanguage(t, "/src/branch/main/foo.c?display=source", "Shell") }) t.Run("file blame view", func(t *testing.T) { defer tests.PrintCurrentTest(t)() - assertFileLanguage(t, "/blame/branch/main/foo.c", "Bash") + assertFileLanguage(t, "/blame/branch/main/foo.c", "Shell") }) })