Skip to content

Commit

Permalink
Display inline code in messages
Browse files Browse the repository at this point in the history
The Textcolor is also set to make sure it is readable
with black on white themes
  • Loading branch information
n-peugnet committed Apr 16, 2022
1 parent e08f23b commit 0da7d78
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ui/messages/html/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0da7d78

Please sign in to comment.