You are here

Line breaks, paragraphs and drupal input filters

Submitted by devblog on Sun, 27/12/2009 - 20:43

One area in Drupal that has always tripped me up is the matter of line breaks, paragraph breaks and formatting.

The culprits here are the Line Break Converter, the HTML Filter and the HTML Corrector.

It is an issue I have always had to work my head around, but I think I am now getting the hang of it.

Wherever the Line Break Converter comes across a line of text ending without a <br /> it adds a <br /> to ensure that when the web browser displays the page, the following text starts on a new line.

When the text if followed by an empty line, it adds a <p> to create a paragraph break, so that web browser displays the following text after adding an empty line.

An observation I made is that if a a <br /> is followed by an empty line, the filtering removes it and converts it to a <p>.

It can get confusing.

Input Formats
==========

Input formats are an issue here as each input format can choose which html tags are stripped out by the html filter. So when you create a new input format it is important to select which html tags are allowed as well as which roles can use them. One really issue is when a user cannot edit an article, and there is no obvious reason why they can't. I once suffered terribly from this issue with Drupal 4.7, forget all about it until it caught me again in Drupal 6, mostly because I often edited my articles as admin until I needed to add more security.

A tool that helps figure it out is devel node access. It comes as a block with the http://drupal.org/project/devel module and has to be enabled and configured to display.

Related Pages
============
http://drupal.fckeditor.net/filters
http://www.lullabot.com/articles/drupal_input_formats_and_filters

Vertical Tabs

Comments

Pages

Add new comment