diff options
Diffstat (limited to 'include/markdown.php')
-rw-r--r-- | include/markdown.php | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/markdown.php b/include/markdown.php index 90d671fe4..d2379e7ed 100644 --- a/include/markdown.php +++ b/include/markdown.php @@ -64,6 +64,12 @@ function markdown_to_bb($s, $use_zrl = false, $options = []) { // Escaping the hash tags $s = preg_replace('/\#([^\s\#])/','#$1',$s); + // Protect mentions from being mangled by the markdown parser + $s = preg_replace_callback( + '|@\{([^}]+)\}|', + fn ($matches) => '@{' . base64_encode($matches[1]) . '}', + $s); + $s = MarkdownExtra::defaultTransform($s); @@ -76,6 +82,12 @@ function markdown_to_bb($s, $use_zrl = false, $options = []) { $s = str_replace("\r","",$s); } + // Restore mentions after markdown conversion + $s = preg_replace_callback( + '|@\{([^}]+)\}|', + fn ($matches) => '@{' . base64_decode($matches[1]) . '}', + $s); + $s = str_replace('#','#',$s); $s = html2bbcode($s); |