Fix room subtitle quotes: second+ quote not green

This commit is contained in:
miruka 2019-09-08 10:48:58 -04:00
parent 916f6d8327
commit 405573bb2d
3 changed files with 5 additions and 8 deletions

View File

@ -11,6 +11,7 @@
- When qml syntax highlighting supports ES6 string interpolation, use that - When qml syntax highlighting supports ES6 string interpolation, use that
- Fixes - Fixes
- 256 min width when a non-image link preview is present
- Pressing backspace in composer sometimes doesn't work - Pressing backspace in composer sometimes doesn't work
- Message order isn't preserved when sending a first message in a E2E - Message order isn't preserved when sending a first message in a E2E
room, then while keys are being shared sending one with another account, room, then while keys are being shared sending one with another account,

View File

@ -20,10 +20,11 @@ class HtmlFilter:
r"(?P<body>magnet:\?xt=urn:[a-z0-9]+:.+)(?P<host>)", r"(?P<body>magnet:\?xt=urn:[a-z0-9]+:.+)(?P<host>)",
]] ]]
inline_quote_regex = re.compile(r"(^\s*&gt;.*)") inline_quote_regex = re.compile(r"(^\s*&gt;.*)", re.MULTILINE)
quote_regex = re.compile( quote_regex = re.compile(
r"(^|<p/?>|<br/?>|<h\d/?>)(\s*&gt;.*?)(</?p>|<br/?>|</?h\d>|$)", r"(^|<p/?>|<br/?>|<h\d/?>)(\s*&gt;.*?)(</?p>|<br/?>|</?h\d>|$)",
re.MULTILINE,
) )
@ -58,9 +59,6 @@ class HtmlFilter:
def filter_inline(self, html: str, outgoing: bool = False) -> str: def filter_inline(self, html: str, outgoing: bool = False) -> str:
text = self._inline_sanitizer.sanitize(html).strip("\n") text = self._inline_sanitizer.sanitize(html).strip("\n")
if outgoing:
return text
return self.inline_quote_regex.sub( return self.inline_quote_regex.sub(
r'<span class="quote">\1</span>', text, r'<span class="quote">\1</span>', text,
) )
@ -72,9 +70,7 @@ class HtmlFilter:
if outgoing: if outgoing:
return html return html
return self.quote_regex.sub( return self.quote_regex.sub(r'\1<span class="quote">\2</span>\3', html)
r'\1<span class="quote">\2</span>\3', html, re.MULTILINE,
)
def sanitize_settings(self, inline: bool = False) -> dict: def sanitize_settings(self, inline: bool = False) -> dict:

View File

@ -80,7 +80,7 @@ HTileDelegate {
) + ": " + ev.inline_content ) + ": " + ev.inline_content
return text.replace( return text.replace(
/< *span +class=['"]?quote['"]? *>(.+)<\/ *span *>/, /< *span +class=['"]?quote['"]? *>(.+)<\/ *span *>/g,
'<font color="' + '<font color="' +
theme.sidePane.room.subtitleQuote + theme.sidePane.room.subtitleQuote +
'">$1</font>', '">$1</font>',