Fallback to "plaintext" lexer in codeblock parser

This avoids "malformed message" in the timeline when the lexer for a
given language is not found.
This commit is contained in:
n-peugnet 2022-10-10 12:36:51 +02:00
parent 75471c3242
commit 82cf2ee816

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 {