Support » Fixing WordPress » paragraphs and soft returns

  • Resolved calsnoboarder

    (@calsnoboarder)


    I know there are plugins (tiny mce for instance) that will stop WP from auto stripping < p > and < br > in html… but exactly why does the WP system delete markup? I’m sure there is a valid reason, but I just don’t know what it is… anyone?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Try: Create a new test post, write in the Text (HTML) tab only, never switch to the Visual tab, and see if you have different results.

    Here are 4 test paragraphs, put all in post:

    <div class="let_me_style_this">
    <p>TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 </p>
    <p>TEST<br>test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 </p>
    <p>TEST test<br>1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 </p>
    <p>TEST test 1<br />TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 TEST test 1 </p></div>

    And we can create some CSS:

    .let_me_style_this {
         color: red;
         font-size: 22pt;
    }

    Tip:

    Differences Between HTML and XHTML:
    In HTML, the <br> tag has no end tag.
    In XHTML, the <br> tag must be properly closed, like this: <br />.

    And this is topic is quite often posted here, for example:

    http://wordpress.org/support/topic/how-to-stop-wordpress-from-stripping-out-breaks?replies=13

    Thread Starter calsnoboarder

    (@calsnoboarder)

    I know if I NEVER return to the visual tab, the line breaks will remain. That isn’t really a solution though… what I am wondering is if there is some specific reason (causes some kind of vulnerability that opens the site up to malicious code) that something as simple and common as line breaks are stripped out. It just seems like something is inherently wrong with a web site publishing system that prevents simple html (or even xhtml) code from being used as needed.

    And I have tried using both the html and xhtml versions of line breaks and wordpress simply strips them out as soon as I click on visual editor.

    While i have no issue working in the text editor exclusively to assure my line breaks remain, my clients who will eventually edit things aren’t really capable of writing code, even simple html… that is afterall, why I chose to use wordpress as the platform for them because it is supposed to be easy enough to build a functional website without actually having to be a coder.

    my clients who will eventually edit things aren’t really capable of writing code

    The HTML editor (as far as I know) cannot be disabled (doing so can lead to many issues with themes and plugins – we can infer from that some things?)

    What I have seen is a few sites noting how to hide the tabs and buttons to access the text editor…

    I have not played with that as I am able to tell users that if they write mangled html, because they switched to the html tab and back, but did not know what they are doing, the post would be deleted or not approved.

    You have seen this, yes:

    http://codex.wordpress.org/Function_Reference/wpautop#Disabling_the_filter

    Thread Starter calsnoboarder

    (@calsnoboarder)

    I don’t want to disable the html editor. I just wanted to find out if anyone knows why hard and soft returns are stripped from the editor.

    I suppose the easiest fix is to simply grab a plugin that disables the function that strips p and br code from a page.

    The link I supplied above deals with your issue. Please review it in detail (including the included links which are about this topic). For example, this one:

    Resources:
    http://ma.tt/scripts/autop/
    ^ is at the bottom on the linked to page

    That page notes:

    By far the most popular code in the site, and has been widely adapted in different projects. Basically it takes PHP’s nl2br function to the logical next step and converts double line breaks to paragraphs where applicable, does line breaks as before, and best of all it’s aware of block-level HTML tags so it won’t mess up your page.

    ma.tt is Matt Mullenweg’s site, a co-founder of WordPress.

    More useful links:

    WordPress Codex
    PHP’s nl2br function
    Google (A Useful Search Engine)

    Thread Starter calsnoboarder

    (@calsnoboarder)

    Again… I am aware of the plugins, function rewrites, etc.

    If you actually read my original post, you’ll see that my question (still unanswered) is:

    “… why does the WP system delete markup? I’m sure there is a valid reason, but I just don’t know what it is… anyone?”

    If you can’t answer that, I understand… but simple copy and paste answer isn’t valid for my question. Thanks for your help though.

    but simple copy and paste answer isn’t valid for my question

    Please read the documentation.

    Thread Starter calsnoboarder

    (@calsnoboarder)

    I understand. But your copy and paste instructions do not actually address my question. I apologize if i wasn’t clear, but my intent was to ask a question since I am well aware of the “solutions” to the problem I was encountering. My original message posed a question about why…

    You can close this thread since I am afraid you will continue to offer solutions to a problem that I have the answers to rather than actually answer the question I asked.

    I am sorry the links did not provide you with what you believe to be the answer. The links explain the process and why.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘paragraphs and soft returns’ is closed to new replies.