widget/reply: formatting syntax for <links>
authorMischa POSLAWSKY <perl@shiar.org>
Fri, 14 May 2021 15:26:40 +0000 (17:26 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 17 May 2021 18:53:38 +0000 (20:53 +0200)
Recognise common <url> notation (as in Markdown), extended for optional link
names after pipe (as in Slack) or whitespace (assuming escaped in urls).

upload.inc.php

index d7d572d31959a5d461240b89072c2eb60f0293d3..86af6049dd49a6fff720deb77c7a1d76afc91dee 100644 (file)
@@ -52,6 +52,9 @@ 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