widget/reply: emphasis formatting over sentences
[minimedit.git] / upload.inc.php
index d7d572d31959a5d461240b89072c2eb60f0293d3..0ee432bc538a8f82f0fe5d1ea135b4524d948b7d 100644 (file)
@@ -52,11 +52,14 @@ function messagehtml($input)
                return $input;  # allow html input as is if privileged
        }
        $markup = [
+               '{&lt;((?:\w+:|/).+?)&gt;}'    => '<$1>',                # unescape link entities
+               '{<(?:https?://)?([^>\s|]+)>}' => '<$1 $1>',             # unnamed link
+               '{<([^>\s|]+)[\s|]([^>]+)>}'   => '<a href="$1">$2</a>', # hyperlink
                "/\r\n?/" => "\n",        # unix newlines
                "/  +\n/" => "<br />",    # trailing spaces for hard line break
                "/\n/"    => "</p>\n<p>", # newlines start paragraphs
-               '/\b_(\w+)_\b/'   => '<em>$1</em>',         # italic
-               '/\b\*(\w+)\*\b/' => '<strong>$1</strong>', # bold
+               '/_(?<!\w_)(.+?)_(?!\w)/'      => '<em>$1</em>',         # italic
+               '/\*(?<!\w\*)(.+?)\*(?!\w)/'   => '<strong>$1</strong>', # bold
        ];
        $html = preg_replace(array_keys($markup), array_values($markup), htmlspecialchars($input));
        return "<p>$html</p>";