WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: TinyMCE Advanced] Inserting <p><br class="spacer_" /></p> (14 posts)

  1. davidwren
    Member
    Posted 4 years ago #

    I am having trouble with the TinyMCE advanced plugin.

    By default the plugin strips all <p> tags, empty or not, if I tick:

    'Stop removing the <p> and <br /> tags when saving and show them in the HTML editor'

    It inserts this code all over the place:

    <p><br class="spacer_" /></p>

    Neither is particularly useful. Anyone else having the same problem? Anyone fixed it?

    I am using WordPress 2.9.2 (despite not being given the option above) and version 3.2.7 of the plugin.

    Cheers

    David

    http://wordpress.org/extend/plugins/tinymce-advanced/

  2. Ian Anderson
    Member
    Posted 4 years ago #

    Yup! I am still having this problem and to be honest it makes using wordpress very cumbersome.

    I think that it must be related to the advanced plugin as I never had problems before.

    I am fine if I stay in html mode but it adds 'spacers' when I save.

    Did you get yours sorted David?
    Cheers
    Ian

  3. erwanpia
    Member
    Posted 4 years ago #

    Hi guys, I had that problem too, solved by commenting

    line 54 in tadv_replace.js
    //c = c.replace(/<p>(\s|<br ?\/?>|\u00a0)*<\/p>/g, '<p><br class="spacer_" /></p>'); // keep empty paragraphs...

    but also in tiny advanced configuration I unchecked the Advanced / stop removing the <p> ...

    I have no br spacer_ anymore ...

  4. gitanoblue
    Member
    Posted 4 years ago #

    Thanks for this suggestion. It worked great. Why on earth is that in there anyway?

  5. Andrew Ozz
    WordPress Dev
    Posted 4 years ago #

    All you need to do is uncheck the option "Stop removing the <p> ..." (which is not checked by default) as @erwanpia suggests. It's there for people who want to add empty paragraphs when typing, otherwise these paragraphs would be removed by wpautop.

  6. Treebeard
    Member
    Posted 4 years ago #

    I checked 'Stop removing the <p> and ' option, but then all my text that does have a break, was running together. It's too shaky to allow a client to have access to the admin if they are going to break the formatting that easily. Is there a fix for this yet? When this is unchecked, the same <p><br class="spacer_" /></p> is appearing all over the place. I don't have to even touch any of the text in the editor, just look at it, and if I hit the Publish button, or switch from HTML to Visual, a bunch more appear.. I'm using 3.0 - any solutions yet (that don't involve editing the plugin files, because the edits would be lost when it's upgraded)?

    Thnx!

  7. caiorg
    Member
    Posted 3 years ago #

    Hi there...

    Cheers everyone... Happy Xmas and New Year (as I write this on December 21st)

    Well... I was having this issue and it was extremely annoying as it made me think going for another editor solution. Which, btw, I was avoiding very hard because I'm building a site for a client and they have no knowledge in HTML at all.

    The point is, I MUST allow the client use blank lines at his will. The option "Stop removing....." did half the work, as it stopped WordPress from removing the blank lines, but "<p><br class="spacer_" /></p>" was being added everytime I switched back and forth to the html editor then to the visual editor. Same problem of some of you have, I think.

    What I did to solve (holpefully permanently) was to change a bit the function pre_format from tadv_replace.js file, located in <wordpress plugin folder>/tinymce-advanced/js folder.

    Bellow is the changed code and the original code (commented):

    c = c.replace(/<p>(\s|<br ?\/?>|\u00a0)*<\/p>/g, '<p><br class="spacer_" /></p>'); // keep empty paragraphs...
            c = c.replace(/\[\/sourcecode\]\s*<br \/>\s*<br \/>/g, '[/sourcecode]');
    		c = c.replace(/<p( [^>]*)?>/g, '<p$1>');
    		c = c.replace(/<\/p>/g, '</p>');
    //		c = c.replace(/<\/p>\s*<p/g, '</p><p');
    		c = c.replace(/<\/p>\r*<p/g, '</p><br class="spacer_" /><p');
    		c = c.replace(/<((blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6])[^>]*)>\s*<p/g, '<$1><p');
    		c = c.replace(/<\/p>\s*<\/(blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6])>/g, '</p></$1>');
    		c = c.replace(/<br ?\/?>[\r]*/g, '<br />');
    		c = c.replace(/<li([^>]*)>/g, '\t<li$1>');
    		c = c.replace(new RegExp('\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*', 'gi'), '[caption$1[/caption]');
    		c = c.replace(new RegExp('caption\\]+\\[caption', 'g'), 'caption][caption');
    
    		// ORIGINAL
    //		c = c.replace(/<p>(\s|<br ?\/?>|\u00a0)*<\/p>/g, '<p><br class="spacer_" /></p>'); // keep empty paragraphs...
    //        c = c.replace(/\[\/sourcecode\]\s*<br \/>\s*<br \/>/g, '[/sourcecode]\n');
    //		c = c.replace(/<p( [^>]*)?>/g, '\n<p$1>');
    //		c = c.replace(/<\/p>/g, '</p>\n');
    //		c = c.replace(/<\/p>\s*<p/g, '</p>\n\n<p');
    //		c = c.replace(/<\/p>\s*<p/g, '</p><br class="spacer_" /><p');
    //		c = c.replace(/<((blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6])[^>]*)>\s*<p/g, '<$1><p');
    //		c = c.replace(/<\/p>\s*<\/(blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6])>/g, '</p></$1>');
    //		c = c.replace(/<br ?\/?>[\r\n]*/g, '<br />\n');
    //		c = c.replace(/<li([^>]*)>/g, '\t<li$1>');
    //		c = c.replace(new RegExp('\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*', 'gi'), '\n\n[caption$1[/caption]\n\n');
    //		c = c.replace(new RegExp('caption\\]\\n\\n+\\[caption', 'g'), 'caption]\n\n[caption');
  8. benny-boy
    Member
    Posted 3 years ago #

    Hi all, just want to post up a quick thanks to Caiorg, for the post above - solved my problem (or seems to have!). Thanks for posting the code up.

  9. georghi
    Member
    Posted 3 years ago #

    Hi

    Thanks for the code change - it seems to work - but I am having a problem with DIVs.

    I need to add DIV tags into the Pages for my client - i did this in HTML view in the Admin. But if he uses IE8 to edit the page content [in Visual view] the Div code gets stripped out when the page is saved.

    any idea how to stop this please?

    thanks

    Phil

  10. caiorg
    Member
    Posted 3 years ago #

    Hey Phil,

    Unfortunately I don't have enough time to spend on this issue. I'm at work and I have other issues to solve (outside WordPress world... lol).

    I am not aware of the specific behaviour of IE on how to interpret javascript, but giving a quick look on that function I saw two lines that may help you start your quest for a solution (if you do find one, post it here with details to help others).

    The lines are:

    c = c.replace(/<((blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6])[^>]*)>\s*<p/g, '<$1><p');
    c = c.replace(/<\/p>\s*<\/(blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6])>/g, '</p></$1>');

    The first one just removes any space character between the tags blockquote, ul, ol, li, table, thead, tbody, tr, th, td, div, h1 to h6 and p.

    The second one do exactly the same, but for the corresponding closing tags.

    As you can see, the div tags are there. This shouldn't be the solution (imho), but try removing these tags from the list on both lines and see what happens.

    Again, post here any feedback you have as it can help others (including me... lol)

    Cheers... and happy coding!

  11. georghi
    Member
    Posted 3 years ago #

    Thanks caiorg

    i tried that - dosen't seem to work unfortunately - it's actually the </div> closer DIV tags that are being removed in IE8 when trying to edit the page.

    I will keep trying - thanks for your help - if you have any other ideas please let me know and I will post here if i find a solution too.

    cheers

    phil

  12. georghi
    Member
    Posted 3 years ago #

    hi caiorg

    sorry - just to check - do you still have STOP REMOVING THE <p> and
    TAGS etc etc - checkbox Ticked or Unticked in TinyMCE Advanced plugin?

    thanks

    Phil

  13. NickStrong
    Member
    Posted 3 years ago #

    Thank you caoirg. Very much ! :)

  14. NickStrong
    Member
    Posted 3 years ago #

    I think one does have to have that checkbox unticked, but I haven't had time to test properly.

Topic Closed

This topic has been closed to new replies.

About this Topic