python-markdownify
python-markdownify copied to clipboard
Whitespace is removed in code
When converting html with <code>
blocks the whitespace ends up with a maximum of one space. This unfortunately means anything with python in codeblocks can't be converted :(
Thanks! Was wondering why my code was doing this.
I don't think this is a bug. <code>
is an inline HTML element per the specification, and thus it does not preserve whitespace. If you render
<code>line1
line2
line3</code>
in a browser, all three words will be on a single line.
You need to enclose your code in a <pre>
block, which is whitespace-preserved per the specification.