From 82cf2ee8169137cddf393ea55008b414df311d14 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Mon, 10 Oct 2022 12:36:51 +0200 Subject: [PATCH] Fallback to "plaintext" lexer in codeblock parser This avoids "malformed message" in the timeline when the lexer for a given language is not found. --- ui/messages/html/parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/messages/html/parser.go b/ui/messages/html/parser.go index e474030..0281e4a 100644 --- a/ui/messages/html/parser.go +++ b/ui/messages/html/parser.go @@ -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 {