When the webmaster has no control on whether the submission is HTML or simple text, this feature becomes useless. Notably, because it will add
by breaking
which screws up the allowed html.
Instead the it should be smart enough to distinuguish between HTML content (which needs no line break) and non-HTML. I solve this by adding a last line in the:
/**
* Convert line breaks into <p> and <br> in an intelligent fashion.
* Based on: http://photomatt.net/scripts/autop
*/
function _filter_autop($text) {
// All block level tags
$block = '(?:html|body ...
$output .= $chunk;
}
//THIS CHECKS IF THERE IS HTML IN THE TEXT
$ishtml = strstr($text,"</");
$output = !empty($ishtml) ? $ishtml.$text : $output;
return $output;
}
Possibly someone may come with a better regexp, but simple text will hardly may have <\.
Comments
Comment #1
magico commentedBut we can be posting "Filtered HTML" which contains HTML. For example if I use
<strong></strong>and want automatically breaks?Comment #2
magico commentedAnyway, I'm closing it because when a user does not have control on how his submission will be processed, it appears on the bottom of the textarea the identification of how the submission will be processed.