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
This commit is contained in:
parent
5e63331f8b
commit
ec17e36911
|
@ -43,4 +43,7 @@ def guess_mime(file: IO) -> Optional[str]:
|
|||
|
||||
|
||||
def plain2html(text: str) -> str:
|
||||
return "<pre>%s</pre>" % html.escape(text)
|
||||
return html.escape(text)\
|
||||
.replace(" ", " ")\
|
||||
.replace("\n", "<br>")\
|
||||
.replace("\t", " " * 4)
|
||||
|
|
Loading…
Reference in New Issue
Block a user