widget/reply: formatting syntax for ~strike~ and `code`
[minimedit.git] / upload.inc.php
index 86af6049dd49a6fff720deb77c7a1d76afc91dee..4f5c5fe564e85b3c133bf53e82630ac249e90915 100644 (file)
@@ -58,8 +58,10 @@ function messagehtml($input)
                "/\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
+               '/~(?<!\w~)(.+?)~(?!\w)/'      => '<s>$1</s>',           # stricken
+               '/`(?<!\w`)(.+?)`(?!\w)/'      => '<code>$1</code>',     # monospace
        ];
        $html = preg_replace(array_keys($markup), array_values($markup), htmlspecialchars($input));
        return "<p>$html</p>";