widget/reply: formatting syntax for _italics_
authorMischa POSLAWSKY <perl@shiar.org>
Fri, 14 May 2021 14:59:48 +0000 (16:59 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 17 May 2021 18:53:38 +0000 (20:53 +0200)
Single underscores for emphasis, as in mail, chat, and Markdown.
Do not cater to advanced usage like partial highlights inside words and
escapes (neither do whatsapp and slack for example); admins can use html
if really needed.

upload.inc.php

index 7810ff6e613da2e065264ae954c291a08b72f383..10881a24a0f9317216339e0b88dc65232afc0207 100644 (file)
@@ -52,8 +52,8 @@ function messagehtml($input)
                return $input;  # allow html input as is if privileged
        }
        $html = preg_replace(
-               ["/\r\n?/", "/  +\n/", "/\n/"],
-               ["\n",      "<br />",  "</p>\n<p>"],
+               ["/\r\n?/", "/  +\n/", "/\n/",      '/\b_(\w+)_\b/'],
+               ["\n",      "<br />",  "</p>\n<p>", '<em>$1</em>'  ],
                htmlspecialchars($input)
        );
        return "<p>$html</p>";