treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Stop WordPress rendering markup inside pre tags

  • G'day guys. This is most likely a simple fix, but how do you stop WordPress from rendering elements inside pre tags? I currently have a plugin installed that is meant to do exactly that (which it does not).

    There are two issues. The first is that I don't want to have to use the HTML entity for <. The second occurs whenever I edit a previous post that has HTML wrapped in pre tags: line breaks magically appear. WordPress must have a default method of formatting markup, which I would love to turn off.
  • @chriscoyier Would you mind sharing what you use to stop WordPress messing about with the stuff in-between pre tags?
  • After continued searching, and trailing, this plugin currently escapes html entities for me: http://coffee2code.com/wp-plugins/preserve-code-formatting/

    Still having problems with they way WordPress formats my code though. For instance, I paste in this:

    <ul>
    <li></li><!--
    --><li></li><!--
    --><li></li>
    </ul>
    That will work fine for the first time. If I am to go back and edit the post at a later date though, this is what I get:


    <ul>
    <li></li>

    <!--
    -->
    <i></li>

    <!--
    -->
    <li></li>
    </ul>
    If anyone else is even experiencing the same thing, please speak up so I know it's not just me.
  • I think for wordpress you need to use < pre >< code >< /code >< /pre >
  • I'll have a play around with that. Thanks for the reply Karl.
  • I think the pre keeps the formatting and the code does the escaping