def normalize_prerendered_loc_html(html: str) -> str: from frontend.views import DOCTYPE_HTML_TAG safe_html = SafeString(html) if safe_html.startswith(DOCTYPE_HTML_TAG): # This is the full HTML of the letter, return it. return safe_html # This is legacy pre-rendered HTML, so it's just the <body>; we # need to render the rest ourselves. ctx: Dict[str, Any] = {"prerendered_letter_content": safe_html} return render_pdf_html(None, "loc/letter-of-complaint.html", ctx, PDF_STYLES_CSS)