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:
parent
75471c3242
commit
82cf2ee816
@ -292,7 +292,7 @@ func tokenToTextEntity(style *chroma.Style, token *chroma.Token) *TextEntity {
|
|||||||
func (parser *htmlParser) syntaxHighlight(text, language string) Entity {
|
func (parser *htmlParser) syntaxHighlight(text, language string) Entity {
|
||||||
lexer := lexers.Get(strings.ToLower(language))
|
lexer := lexers.Get(strings.ToLower(language))
|
||||||
if lexer == nil {
|
if lexer == nil {
|
||||||
return nil
|
lexer = lexers.Get("plaintext")
|
||||||
}
|
}
|
||||||
iter, err := lexer.Tokenise(nil, text)
|
iter, err := lexer.Tokenise(nil, text)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user