From: Mischa POSLAWSKY
Date: Fri, 14 May 2021 15:20:38 +0000 (+0200)
Subject: widget/reply: formatting syntax for *bold*
X-Git-Tag: v5.3~6
X-Git-Url: http://git.shiar.nl/minimedit.git/commitdiff_plain/04a1a7a24edbf8423a48f51609d545a5a7a3eb42
widget/reply: formatting syntax for *bold*
Common chat format but unlike more complicated Markdown **doubling**.
---
diff --git a/upload.inc.php b/upload.inc.php
index 10881a2..d7d572d 100644
--- a/upload.inc.php
+++ b/upload.inc.php
@@ -51,10 +51,13 @@ function messagehtml($input)
if ($User->admin and preg_match('/\A<[a-z][^>]*>/', $input)) {
return $input; # allow html input as is if privileged
}
- $html = preg_replace(
- ["/\r\n?/", "/ +\n/", "/\n/", '/\b_(\w+)_\b/'],
- ["\n", "
", "
\n", '$1' ],
- htmlspecialchars($input)
- );
+ $markup = [
+ "/\r\n?/" => "\n", # unix newlines
+ "/ +\n/" => "
", # trailing spaces for hard line break
+ "/\n/" => "
\n", # newlines start paragraphs
+ '/\b_(\w+)_\b/' => '$1', # italic
+ '/\b\*(\w+)\*\b/' => '$1', # bold
+ ];
+ $html = preg_replace(array_keys($markup), array_values($markup), htmlspecialchars($input));
return "
$html
";
}