WordPress.org

Forums

DIV and Paragraph beheaver in 2.1 (76 posts)

  1. HarryRAR
    Member
    Posted 8 years ago #

    That doesn't solve my problem. Although my problem might be a different one, actually. I just tested again. Without the visual editor, if my code is as I posted earlier:

    <div>
    <a>foo</a>
    <a>foo</a>
    </div>

    it renders it as

    <div>
    <a>foo</a><br />
    <a>foo</a>
    </div>

    which is fine. If the code is:

    <div>
    <a>foo</a>
    
    <a>foo</a>
    </div>

    it puts <p> tags in to keep the white space, which is fine too, except that it doesn't do them properly. It renders it as:

    <div>
    <a>foo</a></p>
    <p><a>foo</a>
    </div>

    Note that there are two missing <p> tags: the first opening tag and the last closing tag. With three or more paragraphs, the middle ones are fine, and the first and last are still wrong.

    Curiously, without the link tags, it's still wrong, but slightly differently. It does the closing tag properly but not the opening one:

    <div>
    foo</p>
    <p>foo</p>
    </div>

    I can live with all this because it is displayed properly in all the browsers I've tested it on, but it doesn't validate. Obviously.

    So it's not the visual editor.

  2. mrshaffly
    Member
    Posted 8 years ago #

    I agree. It is not the visual editor. I'm getting varying results in a form with labels, fieldsets and legends.

    http://www.jacksborochamber.com/membership-application/

    If I take the whitespace out between the closing legend tag and the next table tag, the erronious closing p tag goes away and is replaced by a br.

    <fieldset><legend>Company Name and Contact Information</legend></p>

    Further down the page produces yet another anomoly

    </table>
    <p></fieldset><fieldset><legend>Membership Type</legend></p>

    Moving the whitespace, or lack thereof, around produces different results around the same general areas. I would venture to guess that when 2.1 and 2.1.1 was last updated, the formatting.php file has been changed drastically, or, the built-in editor has.

    This bug really needs to be moved up on the priority list of fixes.

  3. altrugon
    Member
    Posted 8 years ago #

    This is crazy, I've been reading lines and lines of commets in the forurm about the problem with the div and the paragraph in the visual editor since Ella (WP 2.1) was launched, and the problem IS NOT FIXED YET!.

    Please can anybody tell me how to fix this problem. I'm fed up of visiting old posts to fix the code because people are editing them with the visual editor on. Yes, I can use the code editor, but not everybody fell comfortable using it.

    I added the "magic" line below line 66 in wp-includes/formatting.php as say this track, I changed the line 25 as was commented here by silence226, and nothing of that solve my problem because in one way or another my code is allways altered.

    I hope somebody can help me with this bug.

    Thanks

  4. alexleonard
    Member
    Posted 8 years ago #

    I'll add my voice to those experiencing this issue. It's fine on the first post, but if you go back to edit the page everything gets thrown out of order and you have to retype all your code.

    Frustrating.

  5. indextwo
    Member
    Posted 7 years ago #

    I've just started using WordPress 2.2 and, from reading all of these posts, I'm utterly astonished that this issue hasn't been fixed. The completely random adding of <p> tags when I'm putting in *pure code* for all of my pages is extraordinarily annoying; I want it to stick to precisely to the code I put in, not what it *thinks* I should be putting in. Open <p> tags with no closing tags and vice versa now makes a couple of my pages look like I have no idea how to design a page. I do, but unfortunately it appears that WordPress doesn't.

    This has bothered me so much that, since I'm on a deadline, I've scrapped publishing the pages via WordPress and uploading completely static .html files, since I know that they look fine. This is *weak*.

  6. alexleonard
    Member
    Posted 7 years ago #

    Yeah, it's quite an infuriating problem alright. I just wish code view was exactly that, it would definitely make my life easier. Though I'm happy that the div thing can be fixed by editing line 25 of the Tiny MCE file as follows:

    Line 25 reads:

    $valid_elements = 'p/-div[*],-strong/-b[*],-em/-i[*],-font[*],-ul[*],-ol[*],-li[*],*[*]';

    Replace it with the following line

    $valid_elements = '-strong/-b[*],-em/-i[*],-font[*],-ul[*],-ol[*],-li[*],*[*]';

    I still think that there are problems with the code view.

  7. ccoupe
    Member
    Posted 7 years ago #

    Wouldn't hurt to file a bug report on this "new feature".

    I'm not thrilled either with the latest round of of hidden fix "this"but I haven't filed a bug report on 2.2.`. Maybe you have. I'm too busy.

    But i'm with you when you file that bug report. I'm going to wait for Magic to happen.

  8. eaglescout4
    Member
    Posted 7 years ago #

    I'm having the exact same problem as alexleonard when embedding youtube videos. It was not fixed by the above hacks.

    This is what I am seeing. After entering this:

    <object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/yXbvEImWuZU"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/yXbvEImWuZU" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>

    and previewing or saving, the object displays fine.

    But if I save and look at the code it turns into this:

    <object height="350" width="425">
    <param name="movie" value="http://www.youtube.com/v/yXbvEImWuZU"></param>
    <param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/yXbvEImWuZU" type="application/x-shockwave-flash" wmode="transparent" height="350" width="425"></embed></object>

    and then the video is displayed on the side and it destroys the css layout by pushing columns around and centering all of the succeeding text (depending on the particular layout)

    And if I look at the code and save again, it turns into this:

    <object height="350" width="425"></object>
    
    <param name="movie" value="http://www.youtube.com/v/yXbvEImWuZU"></param>
    <param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/yXbvEImWuZU" type="application/x-shockwave-flash" wmode="transparent" height="350" width="425"></embed>

    If I look at the code and save again, the code stays as above.

    Note: I am using version 2.2.1 and I have already used the 2 hacks previously mentioned.

    Despite this problem, I've enjoyed wordpress a lot, so it's not my place to complain.

    I think the code shown above should help whoever is involved with smashing this bug in the upcoming version.

  9. alexleonard
    Member
    Posted 7 years ago #

    I came across some weirdness with You Tube embeds before, however I was trying to embed using valid code and IF IE rules.

    Let's just say that it didn't work at all. Word Press pretty much mangled it out of all shape.

    I didn't have time to consider a work around and I dropped it and just pasted the code as You Tube provides. Which worked fine. I dare not go back in and edit the post though... who knows what will happen to that code.

  10. insideoutsteven
    Member
    Posted 7 years ago #

    I'm having the same problem blogging from Flickr. div tags get replaced with p tags around the photo, and the photo displays improperly in Safari, and not at all in Firefox. It's fine in IE.

  11. emanoelmelo
    Member
    Posted 7 years ago #

    I'm using ImageManager to upload images that displays side by side in a single row that DOES NOT breaks in IE (FF looks fine). So I inserted some
    s to linebreaks (divs dont work) and they are just beign ignored.

  12. popmatik
    Member
    Posted 7 years ago #

    This is still occuring in wordpress 2.3?! why hasnt this been sorted? Has anyone come up with a fix for this?

    I would love to hear it...

  13. HalMacLean
    Member
    Posted 7 years ago #

    Have read through all of this and was none the wiser... however, thanks to the work of my colleague Alex Blanc, we have found a way around the issue in v2.3.1 - we were using wp-contact-form ][ as the plugin and getting 7 validation errors.

    The doc type is set to XHTML 1.0 Transitional. The plug in activated and a new page created. A new page was added to the site and the form added after a short line of text. As expected, the page failed validation. We then followed the advice here - to no avail. On closer inspection we edited the format.php file in a slightly different way.

    Instead of editing after line 66, or deleting any of the lines, he added the following line as line 91:

    $pee = preg_replace( '|</p></form>\s*</p></div>|', "</form></div>", $pee );

    We found that when he edited the function above this line that the issue remained, so the place within the function was important.

    The page now validates, as does the rest of the site. It would be good to know if adding this line works for other folk, too.

  14. OmahaSEO
    Member
    Posted 7 years ago #

    Tried your code on a 2.3.1 - no difference for me.

    My problem is that WP is place an open P tag BEFORE a div tag - thus creating a cascade of open/closed tag errors for validation issue.

  15. HalMacLean
    Member
    Posted 7 years ago #

    Yes - I think it is the same issue and can be resolved in a similar way. You need to get a regular expression going which either removes the P tag entirely, or closes it and moves it, etc. It is a 'find and replace' operation using reg ex that you need, and add it to the function in the format.php file.

  16. johnywhy
    Member
    Posted 7 years ago #

    add my voice to the chorus. WP strips away div tags in my pages. WP, please make this behavior an Option in the options section.

Topic Closed

This topic has been closed to new replies.

About this Topic