From 5aa7946eabd147041a42f3347f447eb53ee0cc47 Mon Sep 17 00:00:00 2001
From: Mischa POSLAWSKY
Date: Sat, 15 May 2021 23:51:24 +0200
Subject: [PATCH] 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.
---
upload.inc.php | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
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));
}
--
2.30.0