Better...
authorx2003bruneau <x2003bruneau@9869982d-c50d-0410-be91-f2a2ec7c7c7b>
Fri, 14 Jul 2006 22:04:53 +0000 (22:04 +0000)
committerx2003bruneau <x2003bruneau@9869982d-c50d-0410-be91-f2a2ec7c7c7b>
Fri, 14 Jul 2006 22:04:53 +0000 (22:04 +0000)
It seems that autoformat behaviour depends a lot on Text::Autoformat version :/

git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@100 9869982d-c50d-0410-be91-f2a2ec7c7c7b

banana/misc.inc.php

index c379ba0..5a76e82 100644 (file)
@@ -427,12 +427,16 @@ function displayShortcuts($first = -1)
  *  FORMATTING STUFF : BODY
  */
 
-function autoformat($text)
+function autoformat($text, $part = false)
 {
     global $banana;
     $length = $banana->wrap;
+    $all = null;
+    if (!$part) {
+        $all = ', all=1';
+    }
     
-    $cmd = "echo ".escapeshellarg($text)." | perl -MText::Autoformat -e 'autoformat {left=>1, right=>$length };'";
+    $cmd = "echo ".escapeshellarg($text)." | perl -MText::Autoformat -e 'autoformat {left=>1, right=>$length$all };'";
     exec($cmd, $result, $ret);
     if ($ret != 0) {
         $result = split("\n", $text);
@@ -486,7 +490,7 @@ function wrap($text, $_prefix="", $_force=false)
                 }
             } else {
                 if (strlen($line) > 2 * $max) {
-                    $next = array_merge($next, autoformat($line));
+                    $next = array_merge($next, autoformat($line, true));
                 } else {
                     $format = true;
                     array_push($next, $line);