A 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.
Nice.I’ll have to try that out.
redwall_hp’s last blog post..2008 U.S. Presidential Election: Candidates’ Sites Compared
It is a short and easy fix. Let me know if it turns out that it doesn’t work for you 😉
Now of course the main question which remains is why was it commented out in the first place :P.
Slevi’s last blog post..Happy valentine sweetie
I believe we have to ask the WordPress Devs about this 😉
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
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.
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;
}
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;
}