I'm writing some questions about programming, and I need to include some
Java code in the question text. But no matter what I do, the editor removes my whitespace (spaces, newlines), flattening the code into one long line.
For example, here is my latest attempt (I have no idea why it doesn't work):
- toggle the editor into HTML mode
- manually enter <pre><code>
- paste Java code from another editor (vim, indenting with spaces)
- manually enter </code></pre>
When I toggle back into normal mode, the code looks fine. But if I return to HTML mode, all extra whitespace is removed. I now have one long line.
The long line is also what I see if I save the question and preview it, so I think the HTML editor is causing the problem.