Merge remote-tracking branch 'n-peugnet/display-inline-code'

This commit is contained in:
Tulir Asokan 2022-04-16 19:26:08 +03:00
commit a8660c7137
2 changed files with 9 additions and 1 deletions

View File

@ -8,6 +8,8 @@
(thanks to [@3nprob] in [#328]).
* Added support for shortcodes *without* tab-completion in `/react`
(thanks to [@tleb] in [#354]).
* Added background color to differentiate `inline code`
(thanks to [@n-peugnet] in [#361]).
* Added tab-completion support for `/toggle` options
(thanks to [@n-peugnet] in [#362]).
* Added initial support for rendering spoilers in messages.
@ -24,6 +26,7 @@
[@n-peugnet]: https://github.com/n-peugnet
[#328]: https://github.com/tulir/gomuks/pull/328
[#354]: https://github.com/tulir/gomuks/pull/354
[#361]: https://github.com/tulir/gomuks/pull/361
[#362]: https://github.com/tulir/gomuks/pull/362
# v0.2.4 (2021-09-21)

View File

@ -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)