From 1437a799e57cdcffc54ca2267406f725106ee50a Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Tue, 20 Oct 2020 13:29:50 +0300 Subject: [PATCH] Don't panic on empty code block. Fixes #237 --- 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 c45e8ce..d7ed66c 100644 --- a/ui/messages/html/parser.go +++ b/ui/messages/html/parser.go @@ -320,7 +320,7 @@ func (parser *htmlParser) syntaxHighlight(text, language string) Entity { func (parser *htmlParser) codeblockToEntity(node *html.Node) Entity { lang := "plaintext" // TODO allow disabling syntax highlighting - if node.FirstChild.Type == html.ElementNode && node.FirstChild.Data == "code" { + if node.FirstChild != nil && node.FirstChild.Type == html.ElementNode && node.FirstChild.Data == "code" { node = node.FirstChild attr := parser.getAttribute(node, "class") for _, class := range strings.Split(attr, " ") {