From: Mischa POSLAWSKY Date: Sat, 15 May 2021 21:51:24 +0000 (+0200) Subject: widget/reply: formatting syntax for unordered lists X-Git-Tag: v5.3~2 X-Git-Url: http://git.shiar.nl/minimedit.git/commitdiff_plain/5aa7946eabd147041a42f3347f447eb53ee0cc47 widget/reply: formatting syntax for unordered lists More complicated block formatting replacing paragraphs by list items. Keep to consecutive regular expressions and html herding while possible instead of complicated code nesting or parsers. --- diff --git a/upload.inc.php b/upload.inc.php index 4f5c5fe..b4a056d 100644 --- a/upload.inc.php +++ b/upload.inc.php @@ -57,12 +57,13 @@ function messagehtml($input) '{<([^>\s|]+)[\s|]([^>]+)>}' => '$2', # hyperlink "/\r\n?/" => "\n", # unix newlines "/ +\n/" => "
", # trailing spaces for hard line break - "/\n/" => "

\n

", # newlines start paragraphs + "/^[-*] (.*)$\n?/m" => '

  • $1
  • ', # list item + "/^(.+)$\n?/m" => "

    $1

    \n", # paragraph + "{^

    (

  • .*
  • )(?:

    \n)?}m" => "\n", # list container '/_(? '$1', # italic '/\*(? '$1', # bold '/~(? '$1', # stricken '/`(? '$1', # monospace ]; - $html = preg_replace(array_keys($markup), array_values($markup), htmlspecialchars($input)); - return "

    $html

    "; + return preg_replace(array_keys($markup), array_values($markup), htmlspecialchars($input)); }