Whitespace is not significant in plain html. Either use Phoenix.HTML.Format.text_to_html to convert whitespace into the related html tags or wrap the whole html in <pre></pre> tags.
Alternative solution, if all you need is to preserve line breaks is to use <pre></pre> tags or CSS properties white-space: pre-wrap; or white-space: pre-line; (tailwind whitespace-pre-line or whitespace-pre-wrap).