As title.. When adding bbcode to a post, drupal ignores all line endings

Comments

gábor hojtsy’s picture

This is by design. If you have certain HTML tags in your posts, newlines will not be added by the Drupal core. The relevant code is in common.inc:

    // get the line breaks right:
    if (strip_tags($text, "<a><i><b><u><tt><code><cite><strong><img>") == $text) {
      $text = nl2br($text);
    }

So if the text contains any of the above tags (after all filters, including bbcode executed), it will not get newlines...

Anonymous’s picture

Well, okay... it's by design...

But how can I modify my code in common.inc so it does break the lines how it's supposed to?
Any idea?

Could you please help me out here?

gábor hojtsy’s picture

This will make the newlines always go into the output even if there is some HTML code inside. Works quite well, if you use bbcode exclusively. The filter system is expected to be redone in Drupal 4.4.0, so these kind of hacks will not be needed...

    // get the line breaks right:
    // if (strip_tags($text, "<a><i><b><u><code><cite><strong>") == $text) {
      $text = nl2br($text);
    // }
gdboling’s picture

Priority: Critical » Normal

I am using Drupal 4.4.1 and bbcode 4.4.0 and this does not appear to have been resolved as stated.