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
|
- Fixes
|
||||||
- `minutesBetween()` for 13:13:58 and 14:15:07
|
- `minutesBetween()` for 13:13:58 and 14:15:07
|
||||||
- `# > quote` doesn't color
|
|
||||||
- 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,
|
||||||
|
|
|
@ -20,6 +20,12 @@ 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*>.*)")
|
||||||
|
|
||||||
|
quote_regex = re.compile(
|
||||||
|
r"(^|<p/?>|<br/?>|<h\d/?>)(\s*>.*?)(<p/?>|<br/?>|<h\d/?>|$)",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self._sanitizer = Sanitizer(self.sanitize_settings())
|
self._sanitizer = Sanitizer(self.sanitize_settings())
|
||||||
|
@ -55,8 +61,8 @@ class HtmlFilter:
|
||||||
if outgoing:
|
if outgoing:
|
||||||
return text
|
return text
|
||||||
|
|
||||||
return re.sub(
|
return self.inline_quote_regex.sub(
|
||||||
r"(^\s*>.*)", r'<span class="quote">\1</span>', text,
|
r'<span class="quote">\1</span>', text,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,10 +72,8 @@ class HtmlFilter:
|
||||||
if outgoing:
|
if outgoing:
|
||||||
return html
|
return html
|
||||||
|
|
||||||
return re.sub(
|
return self.quote_regex.sub(
|
||||||
r"<(p|br/?)>(\s*>.*)(!?</?(?:br|p)/?>)",
|
r'\1<span class="quote">\2</span>\3', html, re.MULTILINE,
|
||||||
r'<\1><span class="quote">\2</span>\3',
|
|
||||||
html,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user