CVS edit link for siliconmeadow

I have a module I've called "EmptyParagraphKiller". I have found that many sites have a need to deal with regular users who often hit the return key twice at the end of a paragraph. For most modern design web sites, where the layout handles the paragraph
spacing for you, the extra empty paragraphs can detract from the look and feel of a site. This module filters out the empty paragraphs of all user entered data on a site. It does this in the Drupal fundamental way such that it never alters the user’s original data - it's non-distructive. I'm currently hosting it here:

https://github.com/siliconmeadow/emptyparagraphkiller

I have searched d.o and can not find a module that does this task. I've posted to the "Contributed Modules Ideas" group here:

http://groups.drupal.org/node/107914

I've also been asked if I was available to help co-maintain the clients module and now have the spare capacity and approval by my company to contribute what I can to the community.

Comments

siliconmeadow’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new1.78 KB

Here is the EmptyParagraphKiller module.

siliconmeadow’s picture

Co-maintainer request:

http://drupal.org/node/978746

manarth’s picture

Status: Needs review » Reviewed & tested by the community

The EmptyParagraphKiller module is well-written, conforms to coding standards and is very clear and easy to understand. If there are any other modules which also provide this feature, I've not come across them.

The co-maintainer request has also been approved by the maintainer of the Web service clients module.

joachim’s picture

Status: Reviewed & tested by the community » Needs work

> $text = preg_replace('#

]*>(\s| ?)*

#', '', $text);

This seems to suppose you're going in *after* the HTML linebreak filter. What if you went before -- the regex would be simpler.

> return t('Empty Paragraph Killer - when entering more than one carriage return, only the first will be honored.');
> ...
> return t('When entering more than one carriage return, only the first will be honored. Users often hit the

Filter tips should be addressed to the user about to type. Compare the voice of these with the filters in core.

> name = Empty Paragraph Killer

IIRC module names are in sentence case.

> EmptyParagraphKiller is a filter module.

Match the name given in the info file.

> such that it never alters the user’s original data - it's

???

> distructive

typo -- 'destructive'

Also, the README needs a CVS tag.

Overall, apart from the points above, code is well-presented and uses Drupal's APIs.

Note that I've not searched for duplicated functionality.

siliconmeadow’s picture

Hi Joachim,

Thanks for taking the time to review this - I'm glad you explained the context of the filter tips and the other points of style.

Regarding the filter kicking in after the line break filter, I hadn't considered that and I'm sure you're right. I need to examine that case and also see what happens with simpler regex if the line break filter isn't enabled and the content entry is completely reliant on a WYSIWYG editor which automatically wraps the return in <p></p>.

Do you think it differs in both cases, and if so, should I provide a contextual switch?

joachim’s picture

> I need to examine that case

I think it's fine to say your filter MUST run before the linebreak filter, or in general, in a particular order relative to others. That's certainly what I do with one of my module's that's a filter.

siliconmeadow’s picture

StatusFileSize
new2.77 KB

It looks to me that perhaps what I should be specifying is that the most likely use (but not exclusive) is on sites using a wysiwyg editor. If the linebreak filter is enabled, it filters multiple carriage returns and produces a similar result to this module.

If you have a wysiwyg editor enabled the linebreak filter does not act on a user's extra use of carriage returns, as it sees those lines as proper content - they have <p> tags.

Please help me in my gap of understanding.

Attached is a patch which adds the CVS tag to the README.txt file, standardises the naming of the module throughout (both sentence case and removal of camelCase) and makes the filter tips more user centric and friendly.

Cheers,

Richard

siliconmeadow’s picture

Title: siliconmeadow [siliconmeadow] » The patch from #7
Status: Needs work » Needs review
StatusFileSize
new2.77 KB

I just noticed that replies don't give you the option to change the status. Should have known, really, because that's the way comments work.

Here it is again. Needs review.

siliconmeadow’s picture

Title: The patch from #7 » siliconmeadow [siliconmeadow]

Sorry - I borked the title earlier.

joachim’s picture

> If the linebreak filter is enabled, it filters multiple carriage returns and produces a similar result to this module.
> If you have a wysiwyg editor enabled the linebreak filter does not act on a user's extra use of carriage returns, as it sees those lines as proper content - they have

tags.

Ohhh... I get it now (I'm all blocked up with cold at the moment, so a bit braindead.... )

So basically, this only applies to input formats that use a wysiwyg, because that causes a P each time you hit return. This could really do to be stated in the readme's introduction.

Hence this filter MUST work with the actual HTML and not line breaks, so that's all fine.

joachim’s picture

BTW, for CVS applications, please reupload the whole module rather than a patch :)

(Note to self or anyone else -- that's probably another item for the guidelines :)

siliconmeadow’s picture

I hadn't really considered that it would be something only useful with a wysiwyg input until now, tbh. I'll adjust README.txt accordingly and upload a new tarball.

Cheers!

siliconmeadow’s picture

StatusFileSize
new1.85 KB

New version with yet more clarity, I hope.

IceCreamYou2’s picture

Line 49, I'm pretty sure <p> tags go outside of calls to t(). Other than that this is RTBC from me, especially considering the co-maintainer request; and I don't think that minor change is worth holding up this application.

siliconmeadow’s picture

StatusFileSize
new1.86 KB

I thought that too, but after looking at the filter_tips in core's filter.module , I noticed it did it both ways (checked out line 180 or so). For shorter passages of text, I'm sure it makes it easier for the translators, so I've taken your advice and moved them out of t(). See the attached version.

Thanks for taking the time to review it!

drupalshrek’s picture

Looks great to me. Anybody who does a good README.txt is already halfway there in my book.

manarth’s picture

Status: Needs review » Reviewed & tested by the community

RTBC from me too.

avpaderno’s picture

Status: Reviewed & tested by the community » Needs review

Can we get a review from joachim, who previously reported what needed to be changed (and did a good job)?

manarth’s picture

Status: Needs review » Reviewed & tested by the community

kiamlaluno: I've marked as RTBC because the co-maintainer request (in #2) meets the requirements based on http://drupal.org/cvs-application/requirements#comaintain (see #978746: Co-maintainer for the request and module maintainer's response).

I'm sure siliconmeadow will welcome any additional comments on the Empty Paragraph Killer module, but I don't think this should hold up the CVS application any further.

avpaderno’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.