Plone Kupu Customization
Kupu is an excellent WYSIWY editor. I has a simple interface but does a lot of heavy lifting behind the scenes. Depending on your HTML code preferences however, Kupu may produce some undesirable source code. Below are a few common fixes.
Many of the formatting adjustments that Kupu makes are derived from the common/kupucontentfilters.js script. Note the use of comments below, to retain the original code. You never know if you'll want to revert back to the original filtering.
Prevent Kupu from replacing <b> tags with <strong> tags
In common/kupucontentfilters.js, change:...
var replaceNodes = { 'b': 'strong', 'i': 'em' };
...to
...
//var replaceNodes = { 'b': 'strong', 'i': 'em' };var replaceNodes = { 'i': 'em' };
...Prevent Kupu from replacing <br /> tags with <p> </p>
In an effort to maintain the use of paragraphs to contain content, Kupu replaces all <br /> tags that are outside of a paragraph with <p> </p>. With a liberally spaced document, this can really clutter up the HTML.
In common/kupucontentfilters.js, change:
if (parentNode.tagName=='body') {
var p = ownerdoc.createElement('p');
var prev = node.previousSibling;
if (prev && prev.nodeType==3) {
p.appendChild(prev);
}
parentNode.insertBefore(p,node);
parentNode.removeChild(node);
} else if (!node.nextSibling && (/(p|div)\b/i.test(parentNode.nodeName) && !(node.previousSibling&&node.previousSibling.nodeName=='br'))) {
parentNode.removeChild(node);
}
to
// if (parentNode.tagName=='body') {
// var p = ownerdoc.createElement('p');
// var prev = node.previousSibling;
// if (prev && prev.nodeType==3) {
// p.appendChild(prev);
// }
// parentNode.insertBefore(p,node);
// parentNode.removeChild(node);
// } else
if (!node.nextSibling && (/(p|div)\b/i.test(parentNode.nodeName) && !(node.previousSibling&&node.previousSibling.nodeName=='br'))) {
parentNode.removeChild(node);
}

