From 0da7d78138a048a2e1399716d5a1531a32eba4c7 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Sun, 10 Apr 2022 22:02:49 +0200 Subject: [PATCH] Display inline code in messages The Textcolor is also set to make sure it is readable with black on white themes --- ui/messages/html/parser.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/messages/html/parser.go b/ui/messages/html/parser.go index a9d6d3f..37f62d4 100644 --- a/ui/messages/html/parser.go +++ b/ui/messages/html/parser.go @@ -139,6 +139,11 @@ func (parser *htmlParser) basicFormatToEntity(node *html.Node) Entity { entity.AdjustStyle(AdjustStyleStrikethrough, AdjustStyleReasonNormal) case "u", "ins": entity.AdjustStyle(AdjustStyleUnderline, AdjustStyleReasonNormal) + case "code": + bgColor := tcell.ColorDarkSlateGray + fgColor := tcell.ColorWhite + entity.AdjustStyle(AdjustStyleBackgroundColor(bgColor), AdjustStyleReasonNormal) + entity.AdjustStyle(AdjustStyleTextColor(fgColor), AdjustStyleReasonNormal) case "font", "span": fgColor, ok := parser.parseColor(node, "data-mx-color", "color") if ok { @@ -357,7 +362,7 @@ func (parser *htmlParser) tagNodeToEntity(node *html.Node) Entity { return parser.headerToEntity(node) case "br": return NewBreakEntity() - case "b", "strong", "i", "em", "s", "strike", "del", "u", "ins", "font", "span": + case "b", "strong", "i", "em", "s", "strike", "del", "u", "ins", "font", "span", "code": return parser.basicFormatToEntity(node) case "a": return parser.linkToEntity(node)