WYSIWYG Force Linebreaks - a Module for Input Format/WYSIWYG Zen

⚠️ Warning
This post is more than 10 years old. I do not delete posts, because even old information is still useful, but please know that some material on this page may be outdated or incorrect. Thanks!
Jan 11, 2011

A few months ago, I was starting to get fed up with having to manually re-patch the WYSIWYG module on about five of my sites every time it was due for an update, to incorporate functionality that I had hoped would make it into WYSIWYG as a regular button/plugin (see issue).

Well, after months of that issue's inactivity, I decided to take the bull by its horns and write up a proper module that would hook into WYSIWYG and allow me to (a) provide the functionality I needed to a wider audience, and (b) save me an extra minute of time per site upgrade (no more patches!).

Thus, WYSIWYG Force Linebreaks was born.

This module helps me with many of my sites - for many different reasons.

  • On some of my sites, I had a lot of content that I had originally entered like I would any comment on drupal.org - two returns for a new paragraph, and don't use any markup (no ugly <p> or <br />'s for me!). This created a problem when I enabled WYSIWYG with TinyMCE or CKEditor—instead of showing the content with paragraphs and line breaks, the whole node would be a jumbled mess of line after contatenated line.
  • On some of my sites, I frequently switch between 'Full HTML' (with WYSIWYG profile) and 'Filtered HTML' or 'PHP code', and having a ton of extra tags in the markup that did nothing other than tell Drupal to make a new paragraph (when the filter system already recognizes new paragraphs using line breaks) made my inner zen off-balance.
  • On other sites, I had to import tons of legacy content, without any proper markup, and when users would edit content in their WYSIWYG editors, all the content would be in one messy paragraph—they'd have to reformat everything.

This module fixes all these problems, and works in Drupal 6 AND Drupal 7, right now.

The image on the module page explains everything rather succinctly:

Don't let your text get messed up - wysiwyg force linebreaks