NicEdit Linebreak Issue – How to fix it

NicEdit - Micro Inline WYSIWYGA lot of bloggers decided to use NicEdit to give their commentors a WYSIWYG editor to style the comment if needed.

NicEdit is a very slim JavaScript WYSIWYG editor which works break, except that some of us bloggers, like Matt at Webmaster-Source, Michael at ProBlogDesign or I myself, experience an odd error when it comes to simple linebreaks inserted by the editor itself.

If you use <br /> on your own, it will work properly. But who uses it if he or she has such a nice editor?

About a month ago I posted the issue on the NicEdit forum and got a reply which told me how to fix it. The author’s forum name of this fix is ihsan and I asked him for his ok about publishing the fix on my blog.

So far he did not reply, so I just go ahead and share it. Full credit for this fix goes to ihsan:

The Fix

open wp-includes/kses.php

find:
//   'br' => array(),

uncomment it: (remove //)
'br' => array(),

Save the file and you are done.

You can read the thread with the fix in the NicEdit forums.

P.S.: ihsan, if you read this, I like to add a link to your homepage/blog if you have one.

8 Gedanken zu „NicEdit Linebreak Issue – How to fix it

  1. it is made that way so that instead of the <br /> tag you can get a </p> with the enter. The best way to insert a <br /> tag instead of actually modifying the original code is to hold Shift then hit enter. (shift + enter). Hope this helps you guys

  2. hi Marco
    Thanks for sharing the information.I am just going to use it on my blog 🙂 thank you very much.
    @Jaime
    thanks for sharing the tip.

  3. I created the following function with regular expressions to clean up HTML. This enters line breaks and tabs in case you need to edit the HTML it will not look horrible

    function br2br(c)
    {
    c = c.replace(/\n?/gi,’\n‘);
    c = c.replace(/\n?\n?/gi,’\n\n‘);
    c = c.replace(/\n?/gi,’\n‘);
    c = c.replace(/\n?\t?]*)>/gi,’\n\t‘);
    return c;
    }

  4. OOPS… the form striped the HTML tags.
    Let me try again:

    function br2br(c)
    {
    c = c.replace(/\n?<(br|hr) ?\/?>/gi,’\n<$1 />‘);
    c = c.replace(/\n?<\/(div|ul|ol|h1|h2|h3|h4|h5|h6)>\n?/gi,’\n</$1>\n‘);
    c = c.replace(/<\/(li|p|table)>\n?/gi,'</$1>\n‘);
    c = c.replace(/\n?\t?<li([^>]*)>/gi,’\n\t<li$1>‘);
    return c;
    }

Schreibe einen Kommentar