From cc64b8c8b52e66aa442f479e25e2a31df44fcb1e Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Wed, 10 Apr 2024 14:49:48 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(backend)=20format=20html=20when=20?= =?UTF-8?q?generate=20document?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When we converted from markdown to html, we didn't format the html, so it was displayed like a string in our pdf. We now format_html the html before we generate the pdf. --- src/backend/core/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backend/core/models.py b/src/backend/core/models.py index 9e4e9b39..3b1c2642 100644 --- a/src/backend/core/models.py +++ b/src/backend/core/models.py @@ -11,6 +11,7 @@ from django.core import mail, validators from django.db import models from django.template.base import Template as DjangoTemplate from django.template.context import Context +from django.utils.html import format_html from django.utils.functional import lazy from django.utils.translation import gettext_lazy as _ @@ -191,7 +192,7 @@ class Template(BaseModel): document_html = HTML( string=DjangoTemplate(self.code).render( - Context({"body": body_html, **metadata}) + Context({"body": format_html(body_html), **metadata}) ) ) css = CSS(