widget/reply: emphasis formatting over sentences
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 15 May 2021 20:18:54 +0000 (22:18 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 17 May 2021 18:53:38 +0000 (20:53 +0200)
Fix boundaries and contents besides simple words.

upload.inc.php

index 86af6049dd49a6fff720deb77c7a1d76afc91dee..0ee432bc538a8f82f0fe5d1ea135b4524d948b7d 100644 (file)
@@ -58,8 +58,8 @@ 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
        ];
        $html = preg_replace(array_keys($markup), array_values($markup), htmlspecialchars($input));
        return "<p>$html</p>";