From: x2003bruneau Date: Sat, 22 Jul 2006 19:34:46 +0000 (+0000) Subject: Fix quotes conversion to html. X-Git-Tag: 1.8~177 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=07f4c9dd158aeed1f78bf30cee6db6c783c2eb51;p=banana.git Fix quotes conversion to html. git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@120 9869982d-c50d-0410-be91-f2a2ec7c7c7b --- diff --git a/banana/misc.inc.php b/banana/misc.inc.php index 66fe305..f717c00 100644 --- a/banana/misc.inc.php +++ b/banana/misc.inc.php @@ -479,16 +479,14 @@ function makeTable($text) * FORMATTING STUFF : BODY */ -function autoformat($text, $part = false) +function autoformat($text) { 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$all };'"; + $cmd = 'echo ' . escapeshellarg($text) + . ' | perl -MText::Autoformat -e \'autoformat {left=>1, right=>' . $length . ', all=>1 };\''; + exec($cmd, $result, $ret); if ($ret != 0) { $result = split("\n", $text); @@ -505,7 +503,7 @@ function wrap($text, $_prefix="", $_force=false) } else { $sign = ''; } - + global $banana; $url = $banana->url_regexp; $length = $banana->wrap; @@ -541,12 +539,8 @@ function wrap($text, $_prefix="", $_force=false) } } } else { - if (strlen($line) > 2 * $max) { - $next = array_merge($next, autoformat($line, true)); - } else { - $format = true; - array_push($next, $line); - } + array_push($next, $line); + $format = true; } } else { array_push($next, $line); @@ -577,6 +571,13 @@ function cleanurl($url) return ''.cutlink($url).''; } +/** Remove quotation marks + */ +function replaceQuotes($text) +{ + return stripslashes(preg_replace("@(^|
|\n)>[ \t\r]*@i", '\1', $text));
+}
+
 function formatbody($_text, $format='plain', $flowed=false)
 {
     if ($format == 'html') {
@@ -611,8 +612,8 @@ function formatbody($_text, $format='plain', $flowed=false)
         while (preg_match("@(^|
|\n)>@i", $res)) {
             $res  = preg_replace("@(^|
|\n)((>[^\n]*\n)+)@ie",
                 "'\\1
'"
-                .".stripslashes(preg_replace('@(^|
|\n)>[ \\t\\r]*@i', '\\1', '\\2'))"
-                .".'
'",
+                ." . replaceQuotes('\\2')"
+                ." . '
'",
                 $res);
         }
         $res = preg_replace("@
-- ?\n@", "
\n-- \n", $res);