From 057829e5a7c99e6fe2ae933cc963c4664674315f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 30 Oct 2023 21:36:28 +0100 Subject: Highlight quotation marks depending on depth. --- mu4web/main.py | 12 +++++++++++- mu4web/static/style.css | 10 ++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mu4web/main.py b/mu4web/main.py index 59f14c7..bbe58cb 100644 --- a/mu4web/main.py +++ b/mu4web/main.py @@ -505,7 +505,17 @@ def response_for(id: str, mail: EmailMessage) -> str: 'height': '300', })) elif at.get_content_type() == 'text/plain': - body.append(('pre', at.get_content())) + items: list[HTML] = [] + for line in at.get_content().split('\n'): + if m := re.match(r'^((> *)+)', line): + for depth, str in enumerate(re.findall('> *', m[1])): + items.append(('span', {'class': f'quote-marker quote-{depth % 5}'}, str)) + items.append(line[m.end():]) + items.append("\n") + else: + items.append(line) + items.append("\n") + body.append(('pre', items)) elif at.get_content_type() == 'application/octet-stream': url = '/part?' + urlencode({'id': id, 'idx': idx}) body.append(('a', {'href': url, diff --git a/mu4web/static/style.css b/mu4web/static/style.css index 75d4a28..0cba3af 100644 --- a/mu4web/static/style.css +++ b/mu4web/static/style.css @@ -135,3 +135,13 @@ table a { display: inline-block; max-width: calc(100vw/4); } + +.quote-marker { + font-weight: bold; +} + +.quote-0 { color: darkcyan; } +.quote-1 { color: magenta; } +.quote-2 { color: goldenrod; } +.quote-3 { color: #00cc00; } +.quote-4 { color: red; } -- cgit v1.2.3