diff --git a/TODO.md b/TODO.md
index d6aab6f9..3cef84e1 100644
--- a/TODO.md
+++ b/TODO.md
@@ -63,6 +63,7 @@
- Prevent using the SendBox if no permission (power levels)
- Spinner when loading past room events, images or clicking buttons
- Parse themes from JSON
+ - Distribute fonts
- Settings page
- Message/text selection
diff --git a/src/python/html_filter.py b/src/python/html_filter.py
index 985f3609..5e59e1a2 100644
--- a/src/python/html_filter.py
+++ b/src/python/html_filter.py
@@ -10,6 +10,11 @@ import html_sanitizer.sanitizer as sanitizer
from html_sanitizer.sanitizer import Sanitizer
+class MarkdownRenderer(mistune.Renderer):
+ def block_quote(self, text: str) -> str:
+ return re.sub(r"^
", "
>", text)
+
+
class HtmlFilter:
link_regexes = [re.compile(r, re.IGNORECASE) for r in [
(r"(?P
[a-zA-Z\d]+://(?P[a-z\d._-]+)"
@@ -29,7 +34,14 @@ class HtmlFilter:
sanitizer.normalize_whitespace_in_text_or_tail = lambda el: el
# hard_wrap: convert all \n to
without required two spaces
- self._markdown_to_html = mistune.Markdown(hard_wrap=True)
+ self._markdown_to_html = mistune.Markdown(
+ hard_wrap=True, renderer=MarkdownRenderer()
+ )
+
+ self._markdown_to_html.block.default_rules = [
+ rule for rule in self._markdown_to_html.block.default_rules
+ if rule != "block_quote"
+ ]
def from_markdown(self, text: str) -> str:
@@ -76,8 +88,8 @@ class HtmlFilter:
}
inlines_attributes = {
- # TODO: translate font attrs to qt html subset
- "font": {"data-mx-bg-color", "data-mx-color"},
+ # TODO: translate font attrs to qt html subset, disallow color
+ "font": {"data-mx-bg-color", "data-mx-color", "color"},
"a": {"href"},
"code": {"class"},
}