Expression Engine 2 Plugin: Empty P Stripper
I’ve got a small little Expression Engine add on., but it might be helpful if you use Pixel and Tonic’s WYGWAM to give your client’s text entry into an Expression Engine textfield a little UX love.
WYGWAM’s a good tool that I’ve used several times on sites. Clients find it an easy thing to pick up. For a recent build though, I kept noticing some strange spacing when my client was using it to create copy. There were empty P tag pairs scattered throughout the copy. I tried tweaking the preferences for CKEditor, which is the engine behind the scenes of WYGWAM, but couldn’t get these empty P tags from happening.
I ended up making a little plug in for the site to solve the problem I was having. I called it Empty P Stripper and is available on GitHub. It’s free and worth every penny. ;-)
(If you’re wondering, yes, it’s a code tweak from my SuperGeekery Tag Stripper. It was different enough that I didn’t want to add clutter to it though.)
Once you’ve got it in your /system/expressionengine/thirdparty/ folder, you can use it like this:
{exp:emptypstripper:stripMyPsPlease}
{wygwym_generated_content}
{/exp:emptypstripper:stripMyPsPlease}
It will turn something like this:
<p>This is a paragraph of text.</p> <hr> <p> </p>
And return this:
<p>This is a paragraph of text.</p> <hr>
Good luck. Let me know if it works for you.