Drupal - How do I get line breaks when using Plain Text format?
This seems like a Drupal 7.x bug. Changing the order of filters doesn't work in my case.
My short term solution was to throw this inside my theme's template.php (ref):
<?php
/**
* Implements template_preprocess_field().
*/
function THEMENAME_preprocess_field(&$vars, $hook) {
// Add line breaks to plain text textareas.
if (
// Make sure this is a text_long field type.
$vars['element']['#field_type'] == 'text_long'
// Check that the field's format is set to null, which equates to plain_text.
&& $vars['element']['#items'][0]['format'] == null
) {
$vars['items'][0]['#markup'] = nl2br($vars['items'][0]['#markup']);
}
}
?>
For fields in views, it's needed to set this option separately in the "Rewrite Results" section of the field settings.
Looks like a bug in Drupal core http://drupal.org/node/1019042
Actually, it should work with this filters order setting at "admin/config/content/formats/plain_text"
- Display any HTML as plain text
- Convert URLs into links
- Convert line breaks into HTML (i.e. <br> and <p>)
Try the filters below by removing "Display any HTML as plain text":
- Limit allowed HTML tags ( set only <a> and <br> for allowed HTML tags list )
- Convert URLs into links
- Convert line breaks into HTML (i.e. <br> and <p>)