WordPress.org

Ready to get started?Download WordPress

Forums

Why does WP put pre tags in paragraphs? (3 posts)

  1. danielb
    Member
    Posted 5 years ago #

    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?

    Thanks!

  2. stvwlf
    Member
    Posted 5 years ago #

    Hi

    The wp-unformatted plugin lets you turn off on a post by post basis WP's tendency to wrap things in <p></p>. You must read the instructions.

    http://wordpress.org/extend/plugins/wp-unformatted/
    Although it says only tested through 2.1, it works fine in 2.7.1

  3. danielb
    Member
    Posted 5 years ago #

    Thanks for the tip.

    The interesting thing is that when installed this plugin I couldn't get it to work. It was very surprising because it's pretty clear and simple. I thought it may be not working because of one of my other plugins, which improves typography (Typo Lite). When I disabled this plugin, not only WP unformatted started to work, but also the issue with incorrect wrapping of P and CODE was gone. So, I'll contact the author of the plugin and ask him to fix it.

    Thanks again )

Topic Closed

This topic has been closed to new replies.

About this Topic