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 10, 2022
1 parent a7562a0 commit 0e3b19f
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 @@ -131,6 +131,11 @@ func (parser *htmlParser) basicFormatToEntity(node *html.Node) Entity {
entity.AdjustStyle(AdjustStyleStrikethrough)
case "u", "ins":
entity.AdjustStyle(AdjustStyleUnderline)
case "code":
bgColor := tcell.ColorDarkSlateGray
fgColor := tcell.ColorWhite
entity.AdjustStyle(AdjustStyleBackgroundColor(bgColor))
entity.AdjustStyle(AdjustStyleTextColor(fgColor))
case "font":
fgColor, ok := parser.parseColor(node, "data-mx-color", "color")
if ok {
Expand Down Expand Up @@ -348,7 +353,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":
case "b", "strong", "i", "em", "s", "strike", "del", "u", "ins", "font", "code":
return parser.basicFormatToEntity(node)
case "a":
return parser.linkToEntity(node)
Expand Down

0 comments on commit 0e3b19f

Please sign in to comment.