Let's say I have a post with a block of code between two paragraphs. Here's what I see in the editor (WYSIWYG is disabled):
first paragraph text <pre>do shell script</pre> second paragraph text
When I publish the post, it turns to
<p>first paragraph text</p> <p><pre>do shell script</pre></p> <p>second paragraph text</p>
This is bad because XHTML doesn't allow including PRE (and other block-level elements in P tags.
If I try to remove extra line breaks between paragraphs and code, on the post page I get such markup:
<p>first paragraph text<br /> <pre>do shell script</pre><br /> second paragraph text</p>
.. which is not better.
Has anybody faced this issue? Is there a way to make WordPress generate valid markup in such cases without hacking its core files?