Interpret **, // and __ as formatting in plain text articles
authorx2003bruneau <x2003bruneau@9869982d-c50d-0410-be91-f2a2ec7c7c7b>
Sat, 8 Jul 2006 20:42:03 +0000 (20:42 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 4 Jan 2008 23:34:47 +0000 (00:34 +0100)
git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@63 9869982d-c50d-0410-be91-f2a2ec7c7c7b

Changelog
banana/misc.inc.php

index 6e53e82..1a53c55 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -3,6 +3,7 @@ Sat, 08 Jul 2006                    Florent Bruneau <florent.bruneau@m4x.org>
        * Automatically set fup for crossposts
        * Full URL redirection
        * Link abstraction
+       * Interpret **, // and __ as formatting in plain text articles
 
 ================================================================================
 VERSION 1.3
index 8d905e3..5161b0d 100644 (file)
@@ -484,7 +484,13 @@ function formatbody($_text, $format='plain', $flowed=false)
                    .".'</pre></blockquote><pre>'",
                    $res);
         }
-       $res = preg_replace("@<pre>-- ?\n@", "<pre>\n-- \n", $res);
+               $formatting = Array('\*' => 'strong',
+                                                       '_' => 'u',
+                                                       '/' => 'em');
+               foreach ($formatting as $limit=>$mark) {
+                       $res = preg_replace('@' . $limit . '([^\s]+)' . $limit . '@', "<$mark>\\1</$mark>", $res);
+               }
+               $res = preg_replace("@<pre>-- ?\n@", "<pre>\n-- \n", $res);
         $parts = preg_split("/\n-- ?\n/", $res);
     }