diff --git a/NEWS b/NEWS index d5b787a3..87cbe2c2 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ + - adjusted textformat to not output wrap chars after last para + (Monte) - use tempnam() instead of unqid() to create better temporary files in smarty_core_write_file() (xces, messju) - add 'mail' to escape modifier for safe display of e-mail diff --git a/libs/plugins/block.textformat.php b/libs/plugins/block.textformat.php index 760b313f..aaebab2f 100644 --- a/libs/plugins/block.textformat.php +++ b/libs/plugins/block.textformat.php @@ -71,33 +71,30 @@ function smarty_block_textformat($params, $content, &$smarty) } // split into paragraphs - $paragraphs = preg_split('![\r\n][\r\n]!',$content); - $output = ''; + $_paragraphs = preg_split('![\r\n][\r\n]!',$content); + $_output = ''; - foreach ($paragraphs as $paragraph) { - if ($paragraph == '') { + for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) { + if ($_paragraphs[$_x] == '') { continue; } // convert mult. spaces & special chars to single space - $paragraph = preg_replace(array('!\s+!','!(^\s+)|(\s+$)!'),array(' ',''),$paragraph); + $_paragraphs[$_x] = preg_replace(array('!\s+!','!(^\s+)|(\s+$)!'), array(' ',''), $_paragraphs[$_x]); // indent first line if($indent_first > 0) { - $paragraph = str_repeat($indent_char,$indent_first) . $paragraph; + $_paragraphs[$_x] = str_repeat($indent_char, $indent_first) . $_paragraphs[$_x]; } // wordwrap sentences - $paragraph = wordwrap($paragraph, $wrap - $indent, $wrap_char, $wrap_cut); + $_paragraphs[$_x] = wordwrap($_paragraphs[$_x], $wrap - $indent, $wrap_char, $wrap_cut); // indent lines if($indent > 0) { - $paragraph = preg_replace('!^!m',str_repeat($indent_char,$indent),$paragraph); + $_paragraphs[$_x] = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraphs[$_x]); } - $output .= $paragraph . $wrap_char . $wrap_char; } + $_output = implode($wrap_char . $wrap_char, $_paragraphs); + + return $assign ? $smarty->assign($assign, $_output) : $_output; - if ($assign) { - $smarty->assign($assign,$output); - } else { - return $output; - } } /* vim: set expandtab: */