Fix html quote regex
Also allow quoting in title, e.g. "# > blah blah blah"
This commit is contained in:
parent
07fb63aa1e
commit
9f8bdfc6fb
1
TODO.md
1
TODO.md
|
@ -12,7 +12,6 @@
|
|||
|
||||
- Fixes
|
||||
- `minutesBetween()` for 13:13:58 and 14:15:07
|
||||
- `# > quote` doesn't color
|
||||
- Pressing backspace in composer sometimes doesn't work
|
||||
- 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,
|
||||
|
|
|
@ -20,6 +20,12 @@ class HtmlFilter:
|
|||
r"(?P<body>magnet:\?xt=urn:[a-z0-9]+:.+)(?P<host>)",
|
||||
]]
|
||||
|
||||
inline_quote_regex = re.compile(r"(^\s*>.*)")
|
||||
|
||||
quote_regex = re.compile(
|
||||
r"(^|<p/?>|<br/?>|<h\d/?>)(\s*>.*?)(<p/?>|<br/?>|<h\d/?>|$)",
|
||||
)
|
||||
|
||||
|
||||
def __init__(self) -> None:
|
||||
self._sanitizer = Sanitizer(self.sanitize_settings())
|
||||
|
@ -55,8 +61,8 @@ class HtmlFilter:
|
|||
if outgoing:
|
||||
return text
|
||||
|
||||
return re.sub(
|
||||
r"(^\s*>.*)", r'<span class="quote">\1</span>', text,
|
||||
return self.inline_quote_regex.sub(
|
||||
r'<span class="quote">\1</span>', text,
|
||||
)
|
||||
|
||||
|
||||
|
@ -66,10 +72,8 @@ class HtmlFilter:
|
|||
if outgoing:
|
||||
return html
|
||||
|
||||
return re.sub(
|
||||
r"<(p|br/?)>(\s*>.*)(!?</?(?:br|p)/?>)",
|
||||
r'<\1><span class="quote">\2</span>\3',
|
||||
html,
|
||||
return self.quote_regex.sub(
|
||||
r'\1<span class="quote">\2</span>\3', html, re.MULTILINE,
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user