Color reply prefix in room delegate last message

This commit is contained in:
miruka 2021-04-15 07:27:54 -04:00
parent a208ba3991
commit de7e14f9ca
2 changed files with 8 additions and 6 deletions

View File

@ -124,6 +124,7 @@ class HTMLProcessor:
inline_tags = {
"span", "font", "a", "sup", "sub", "b", "i", "s", "u", "code",
"mx-reply",
}
block_tags = {
@ -479,7 +480,7 @@ class HTMLProcessor:
def _reply_to_inline(self, el: HtmlElement) -> HtmlElement:
"""Turn <mx-reply> into a plaintext inline form."""
"""Shorten <mx-reply> to only include the replied to event's sender."""
if el.tag != "mx-reply":
return el
@ -487,11 +488,10 @@ class HTMLProcessor:
try:
user_id = el.find("blockquote").findall("a")[1].text
text = f"{user_id[1:].split(':')[0]}: " # U+21A9 arrow
except (AttributeError, IndexError):
text = "" # U+21A9 arrow
except (AttributeError, IndexError) as e:
return el
el.clear()
el.tag = "span"
el.text = text
return el

View File

@ -127,8 +127,10 @@ HTile {
return text.replace(
/< *span +class=['"]?quote['"]? *>(.+?)<\/ *span *>/g,
`<font color="${subColor}">` +
`$1</font>`,
`<font color="${subColor}">$1</font>`,
).replace(
/< *mx-reply *>(.+?)<\/ *mx-reply *>/g,
`<font color="${theme.colors.accentText}">$1</font>`,
)
}
}