Request: strip newlines but treat newlines newlines as paragraph
-
I’m still struggling to get plain test emails to post correctly. I’ve tried filtering newlines but that runs all my text together. I’ve tried not filtering newlines but that breaks text at the plane text email per-define line length.
I’ve decided what would be ideal is to treat newline different from newline+newline. The relevant code is here:
//filter content for new lines function filter_Newlines(&$content, $config) { if ($config['filternewlines']) { $search = array( "/\r\n/", "/\n\n/", "/\r\n\r\n/", "/\r/", "/\n/" ); $replace = array( "LINEBREAK", "LINEBREAK", 'LINEBREAK', 'LINEBREAK', 'LINEBREAK' ); $result = preg_replace($search, $replace, $content); if ($config['convertnewline']) { $content = preg_replace('/(LINEBREAK)/', "<br />\n", $result); } else { $content = preg_replace('/(LINEBREAK)/', " ", $result); } } }
Temporarily I plan to change this code so it will FILTER but not CONVERT instances of single newline, but leave double newline instances.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Request: strip newlines but treat newlines newlines as paragraph’ is closed to new replies.