From ec17e36911045987534cb5b4c67d9fe90d0a5212 Mon Sep 17 00:00:00 2001 From: miruka Date: Sat, 17 Aug 2019 15:05:05 -0400 Subject: [PATCH] Better plain text to html conversion Replace \n and space characters instead of just wrapping the whole text in pre and having to set a css style --- src/python/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/python/utils.py b/src/python/utils.py index 1222e1c4..3ae437df 100644 --- a/src/python/utils.py +++ b/src/python/utils.py @@ -43,4 +43,7 @@ def guess_mime(file: IO) -> Optional[str]: def plain2html(text: str) -> str: - return "
%s
" % html.escape(text) + return html.escape(text)\ + .replace(" ", " ")\ + .replace("\n", "
")\ + .replace("\t", " " * 4)