* 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);
} else {
$sign = '';
}
-
+
global $banana;
$url = $banana->url_regexp;
$length = $banana->wrap;
}
}
} 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);
return '<a href="'.$url.'" title="'.$url.'">'.cutlink($url).'</a>';
}
+/** Remove quotation marks
+ */
+function replaceQuotes($text)
+{
+ return stripslashes(preg_replace("@(^|<pre>|\n)>[ \t\r]*@i", '\1', $text));
+}
+
function formatbody($_text, $format='plain', $flowed=false)
{
if ($format == 'html') {
while (preg_match("@(^|<pre>|\n)>@i", $res)) {
$res = preg_replace("@(^|<pre>|\n)((>[^\n]*\n)+)@ie",
"'\\1</pre><blockquote><pre>'"
- .".stripslashes(preg_replace('@(^|<pre>|\n)>[ \\t\\r]*@i', '\\1', '\\2'))"
- .".'</pre></blockquote><pre>'",
+ ." . replaceQuotes('\\2')"
+ ." . '</pre></blockquote><pre>'",
$res);
}
$res = preg_replace("@<pre>-- ?\n@", "<pre>\n-- \n", $res);