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 = { inline_tags = {
"span", "font", "a", "sup", "sub", "b", "i", "s", "u", "code", "span", "font", "a", "sup", "sub", "b", "i", "s", "u", "code",
"mx-reply",
} }
block_tags = { block_tags = {
@ -479,7 +480,7 @@ class HTMLProcessor:
def _reply_to_inline(self, el: HtmlElement) -> HtmlElement: 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": if el.tag != "mx-reply":
return el return el
@ -487,11 +488,10 @@ class HTMLProcessor:
try: try:
user_id = el.find("blockquote").findall("a")[1].text user_id = el.find("blockquote").findall("a")[1].text
text = f"{user_id[1:].split(':')[0]}: " # U+21A9 arrow text = f"{user_id[1:].split(':')[0]}: " # U+21A9 arrow
except (AttributeError, IndexError): except (AttributeError, IndexError) as e:
text = "" # U+21A9 arrow return el
el.clear() el.clear()
el.tag = "span"
el.text = text el.text = text
return el return el

View File

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