From 3ce06a938c5bda57e846462ba41b742a84dd0afd Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Sat, 27 Apr 2024 01:05:29 +0530 Subject: [PATCH] Render scheduled task response as html to improve readability in email --- pyproject.toml | 1 + src/khoj/routers/email.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fa1db686..498be35e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,6 +76,7 @@ dependencies = [ "django-phonenumber-field == 7.3.0", "phonenumbers == 8.13.27", "markdownify ~= 0.11.6", + "markdown-it-py ~= 3.0.0", "websockets == 12.0", "psutil >= 5.8.0", "huggingface-hub >= 0.22.2", diff --git a/src/khoj/routers/email.py b/src/khoj/routers/email.py index ba28d029..96eb5d85 100644 --- a/src/khoj/routers/email.py +++ b/src/khoj/routers/email.py @@ -6,6 +6,7 @@ try: except ImportError: pass +import markdown_it from django.conf import settings from jinja2 import Environment, FileSystemLoader @@ -56,7 +57,8 @@ def send_task_email(name, email, query, result): template = env.get_template("task.html") - html_content = template.render(name=name, query=query, result=result) + html_result = markdown_it.MarkdownIt().render(result) + html_content = template.render(name=name, query=query, result=html_result) resend.Emails.send( {