Merge pull request #386 from n-peugnet/lexer-fallback

Fallback to "plaintext" lexer in codeblock parser
This commit is contained in:
Tulir Asokan 2022-10-18 13:56:23 +03:00 committed by GitHub
commit ae10e8ebd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -292,7 +292,7 @@ func tokenToTextEntity(style *chroma.Style, token *chroma.Token) *TextEntity {
func (parser *htmlParser) syntaxHighlight(text, language string) Entity {
lexer := lexers.Get(strings.ToLower(language))
if lexer == nil {
return nil
lexer = lexers.Get("plaintext")
}
iter, err := lexer.Tokenise(nil, text)
if err != nil {