cvs: smarty / NEWS /libs/plugins block.textformat.php

"Monte Ohrt" <[email protected]>
Newsgroups gmane.comp.php.cvs.smarty
Message-ID <cvsmohrt1083970211@cvsserver>
mohrt		Fri May  7 18:50:11 2004 EDT

  Modified files:              
    /smarty	NEWS 
    /smarty/libs/plugins	block.textformat.php 
  Log:
  update textformat to not output wrap chars after last para
  
  
http://cvs.php.net/diff.php/smarty/NEWS?r1=1.450&r2=1.451&ty=u
Index: smarty/NEWS
diff -u smarty/NEWS:1.450 smarty/NEWS:1.451
--- smarty/NEWS:1.450	Thu May  6 08:37:45 2004
+++ smarty/NEWS	Fri May  7 18:50:11 2004
@@ -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
http://cvs.php.net/diff.php/smarty/libs/plugins/block.textformat.php?r1=1.7&r2=1.8&ty=u
Index: smarty/libs/plugins/block.textformat.php
diff -u smarty/libs/plugins/block.textformat.php:1.7 smarty/libs/plugins/block.textformat.php:1.8
--- smarty/libs/plugins/block.textformat.php:1.7	Fri Dec 19 12:20:19 2003
+++ smarty/libs/plugins/block.textformat.php	Fri May  7 18:50:11 2004
@@ -71,33 +71,30 @@
     }
 
     // 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: */

-- 
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.