aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kostikov <max@kostikov.co>2019-11-08 23:35:05 +0100
committerMax Kostikov <max@kostikov.co>2019-11-08 23:35:05 +0100
commit478014f02a9241ec6d5b5e9672968897176302d2 (patch)
treec26098c1c0ebff705dc4ef4f324b8b1656c61b9a
parentaff7c2d771bd5ba073d26e7f621c32012ce22c2a (diff)
downloadvolse-hubzilla-478014f02a9241ec6d5b5e9672968897176302d2.tar.gz
volse-hubzilla-478014f02a9241ec6d5b5e9672968897176302d2.tar.bz2
volse-hubzilla-478014f02a9241ec6d5b5e9672968897176302d2.zip
Better BBcode to Markdown conversion
-rw-r--r--include/markdown.php7
1 files changed, 5 insertions, 2 deletions
diff --git a/include/markdown.php b/include/markdown.php
index 213986867..69cc264df 100644
--- a/include/markdown.php
+++ b/include/markdown.php
@@ -246,6 +246,9 @@ function bb_to_markdown($Text, $options = []) {
call_hooks('bb_to_markdown_bb', $x);
$Text = $x['bbcode'];
+
+ // Replace spoiler tag before BBcode conversion
+ $Text = preg_replace("/\[\/?spoiler\]/is", "\n--- " .t('spoiler') . " ---\n", $Text);
// Convert it to HTML - don't try oembed
$Text = bbcode($Text, [ 'tryoembed' => false ]);
@@ -265,8 +268,8 @@ function bb_to_markdown($Text, $options = []) {
// Remove empty zrl links
$Text = preg_replace("/\[zrl\=\].*?\[\/zrl\]/is", "", $Text);
- // Remove unprocessed spoiler HTML tags
- $Text = preg_replace("/<div.+>([^<]+)<.+>(>.+)$/im", "$1\n$2", $Text);
+ // Replace unprocessed <br> in code
+ $Text = str_replace("<br></br>", "\n", $Text);
$Text = trim($Text);